I have some regions defined in a dataset that looks like this:
> head(regions_gg)
lon lat group
12 -69.75 -19.75 3
13 -69.25 -19.75 3
14 -68.75 -19.75 3
15 -68.25 -19.75 3
16 -67.75 -19.75 3
17 -67.25 -19.75 3
where every point in space has assigned a number, which indicates which region it belongs to.
What I want to do is outline these regions and create a border around them.
So far, this is the best I could do, but as you can see, it looks hideous.
ggplot(regions_gg,aes(x=lon,y=lat,fill=group,z=group))+theme_bw()+
geom_raster(interpolate=F)+geom_contour()
geom_contour() is trying to interpolate and adds a lot of unnecessary lines. Is there an easy way to fix this?
EDIT: here's the data
regions_gg
Related
New to the R/ggplot.
I have a data set like this. Each mol-code is made of 3 components and copies represent how many times each mol-code appears. There are 8 unique components available and it is represented as smile files.
full.mol.code2 Copies Pair1.Acids Pair2.Acids Pair3.Acids
1 1.301241e+23 18 OC(C1=COC(CCl)=N1)=O OC(C1=CC=C(CCl)C=C1)=O O=C(O)C1=C(C)OC=C1
2 1.303241e+23 18 OC(C1=CSC(CCl)=N1)=O OC(C1=CSC(CCl)=N1)=O OC([C#H](C)Br)=O.[R]
3 1.301241e+23 17 OC(C1=COC(CCl)=N1)=O OC(C1=COC(CCl)=N1)=O O=C(O)C1=C(C)OC=C1
4 1.304241e+23 12 ClC/C(C)=C/[C##H](C)C(O)=O OC(C1=COC(CCl)=N1)=O OC([C#H](C)Cl)=O.[S]
5 1.309240e+23 12 OC(C1=CSC(CCl)=N1)=O OC(C1=CC=C(CCl)C=C1)=O O=C(O)C1=C(C)OC=C1
6 1.301241e+23 11 OC(C1=COC(CCl)=N1)=O OC(C1=CC=C(CCl)C=C1)=O OC([C#H](C)Cl)=O.[S]
Edit: thanks Allan for formatting this properly.
'full.mol.code2' is a number like this (130124051501260617102804), it will not be considered as value.
I want to represent this data in a barplot where x-axis will be mol-code and y-axis represents copies and each bar represent the combination of three components in different color.
I hope that made sense and appreciate any help.
Thanks.
I am new to R and I have been trying to make a line graph with mupltiple lines. I have tried the 'plot' function but didn't get the desired result so I am now trying the ggplot.
I keep running into error:
Aesthetics must be either length 1 or the same as the data (100): x
and there's obviously no graph output.
Any help is much appreciated
I have rearranged my data, before it had 4 separate columns for different consumer types but now I have merged them and made a column that identifies each consumer.
This is the part of the code that generates the error
ggplot(data=consumers,aes(x=scenarios,y=unitary.bill)) +
geom_line(aes(color=consumer.type,group=consumer.type))
my data looks like this:
scenario unitary.bill consumer.type
1 1 0.076536835 net.cons
2 2 0.075835361 net.cons
3 3 0.076696548 net.cons
4 4 0.076431602 net.cons
5 5 0.076816135 net.cons
.........
27 2 0.076794287 smart.cons
28 3 0.075555555 smart.cons
29 4 0.077126955 smart.cons
30 5 0.077925161 smart.cons
.......
100 25 0.049247761 smart.pros
I expect the a line graph to have four different colors (each representing my consumer type) and the scenarios at the x-axis.
Thanks for all the help from Camille and Infominer. My code now looks like this (I added some more details)
ggplot(data=consumers,aes(x = scenarios,y = unitary.bill, colour= SMCs)) +
geom_line(size=1) + scale_colour_manual(values=c("indianred1", "yellowgreen","lightpink","springgreen4"))+
ggtitle(" Unitary bill for each SMC type at the end of the scenario runs")+
scale_x_continuous(breaks=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25))
and the graph looks as I wanted it to. However, if I could put some more distance between the title and the graph that will make it prettier.
you can view the graph here
To put it simple, I have three columns in excel like the ones below:
Vehicle x y
1 10 10
1 15 12
1 12 9
2 8 7
2 11 6
3 7 12
x and y are the coordinates of customers assigned to the corresponding vehicle. This file is the output of a program I run in advance. The list will always be sorted by vehicle, but the number of customers assigned to vehicle "k" may change from one experiment to the next.
I would like to plot a graph containing 3 series, one for each vehicle, where the customers of each vehicle would appear (as dots in 2D based on their x- and y- values) in different color.
In my real file, I have 12 vehicles and 3200 customers, and the ranges change from one experiment to the next, so I would like to automate the process, i.e copy-paste the list on my excel and see the graph appear automatically (if this is possible).
Thanks in advance for your time and effort.
EDIT: There is a similar post here: Use formulas to select chart data but requires the use of VB. Moreover, I am not sure whether it has been indeed answered.
you should try this free online tool - www.cloudyexcel.com/excel-to-graph/
for different classes i have NSCC count ,now i have to make line chart showing this NSCC count falling in range like 1-10 is low risk,10-20 is moderate risk,20-50 is high risk and above 50 horrible.How to plot data with this range on x axis?And how to color different range width.
Please help me
One possible solution is use Multiple Line series with different Color
i suppose you have data some thing like this
|NSCC| |count|
A 10
B 12
C 54
D 25
you could convert to matrix like
|NSCC| |count| |LOW| |MODERATE| |HIGH|
A 10 10 null null
B 12 12 null null
C 54 null null 54
D 25 null 25 null
and create Multiple Line Series on chart,
you may found split among series, to overcome this you could add dummy boundry points
There are also other options like
Use customize background with differnt colors
Use customize itemrendrer
Hopes that Helps
I'm trying to organize the data in the file.dat, such that I could then use gnuplot for bar chart creation. Namely, the current data looks like:
Nodes Rows PS
30 0 0.16545666
30 5 0.13318791
30 10 0.13621247
30 993 0.17842487
31 0 0.26545666
31 5 0.23318791
31 10 0.23621247
31 992 0.27842487
I would like to create bar charts that would have Nodes (30 and 31) at the x axis, and PS
values on the y axis. The data in Rows should be accumulated side-to-size around the base which is Nodes. For instance, the chard would have displayed bar showing PS for Nodes 30, Rows 0, to its immediate right side should be the bar showing PS for Nodes 30, but with Rows 5... then, after Nodes 30 is finished, there should be a gap to 31 (or 5 gaps if 35 is considered), with similar accumulation.
How may I achieve this with gnuplot? In case I should reorganize the data, please consider including the sequence of code I should invoke for a particular organization.
Thanks.
If you reorganize your data to
30 0 0.16545666 5 0.13318791 10 0.13621247 993 0.17842487
31 0 0.26545666 5 0.23318791 10 0.23621247 992 0.27842487
which is Nodes row_1 ps_1 row_2 pw_2 ..., I think you can plot your data with
set key off
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.9
plot for [col=3:7:2] "Data.csv" u col:xticlabels(1)
which gives you this plot: