Organizing data for gnuplot barcharts - plot

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:

Related

How do I draw region borders with ggplot? - R

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

Graph in SAS coming up with strange values using gchart function

I am trying to create a graph from a table I've made. I want to graph the values for month with the numbers in the Scheduled column. Unfortunately, it is displaying the months as like .75 or 2.25 and 4.75 instead of the actual month numbers and I don't know why.
I have tried changing the type of graph, the sumvar, the axes and values for them, but none of this has helped... it worked at one point but then simply stopped and I cannot figure out why.
1 SKED 7573
1 UNSK 1882
2 SKED 6635
2 UNSK 1642
3 SKED 817
3 UNSK 208
4 SKED 9494
4 UNSK 2376
5 SKED 1900
5 UNSK 551
6 SKED 9864
6 UNSK 3319
7 SKED 9770
7 UNSK 4145
pattern1 value=solid color=CXc01933;
pattern2 value=solid color=CX003366;
axis1 label=(angle=90 'Amount of Wheelchair Requests');
axis2 label=('Month') order=(0 to 12 by 1);
proc gchart data=Overall_Arr;
vbar month / type=sum SUMVAR=Arr_num subgroup=scheduled raxis=axis1 maxis=axis2
autoref clipref ;
run;
This is the table and this is the code to make the graph. I am expecting an output of a graph with two different colored bars, signifying the scheduled number and the unscheduled number. Before I put the order on the second axis it would output a graph but would have strange numbers for the month, like .75 or 4.25, etc, instead of using the 1 2 3 etc to signify the months. Now it is outputting no bars, I am assuming because it is trying to use those weird numbers but I've restricted the axis to whole numbers for the month... Any help would be appreciated.
Alright I actually think I figured it out, the problem was that month is also a command, so changing my variable's name allowed for it to be a variable instead of a command.

Trying to make a graph with multiple lines using ggplot

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

How to create an interval file defined by values from another file - for circos imaging of WGS data

I am trying to depict my whole-genome sequence (WGS) data of my parasite, using the circos software.
One of the elements I would like to depict, is the areas of the reference genome for which i do not have sequencing data from my parasite.
I order to do this, I have used Samtools to create an mpileup file, from which I have extracted the positions where the sequence depth = 0. I therefore have a file that looks like this:
$chromosome_name $chromosome_position $depth
chr_1 1 0
chr_1 2 0
chr_1 3 0
chr_2 67 0
chr_2 68 0
chr_2 1099 0
chr_2 1100 0
chr_2 1101 0
this means that there are 3 positions in chromosome 1, with no sequence data (depth = 0): namely positions 1, 2 and 3. For chromosome 2, the positions with no data are positions 67, 68, 1099, 1100 and 1101.
Due to the fact that my files are enormous (up to 3 million lines), and the fact that alot of the unsequenced positions come in intervals, I would like to create an interval file from the above data. Also, circos requires such an interval-file in order to create tiles. I therefore need to create a new file from the above, that looks like this:
$chromosome_name $start_pos $end_pos
chr_1 1 3
chr_2 67 68
chr_2 1099 1101
I have searched a bunch, but I have only found questions pertaining to grouping data by pre-defined intervals (e.g. group purchases occurring over a period of 6 months, patients by age etc).
So if anybody can help me out, I will be extremely happy!
Sidsel
Consider using bedtools. Specifically the bedtools merge sub-command:
http://bedtools.readthedocs.io/en/latest/content/tools/merge.html
From this page, it would seem to do what you want:
bedtools merge combines overlapping or “book-ended” features in an
interval file into a single feature which spans all of the combined
features.
Moreover, you can use the -d option to specify max distance between featured to merge:
-d Maximum distance between features allowed for features to be merged. Default is 0. That is, overlapping and/or book-ended features
are merged.

different color for different range on x axis of line chart in flex 4.6

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

Resources