I want to plot a single curve of data values versus time values, both of which come from a binary file. Both of these sets (data and time) are stored as 59, 4-byte floats. The data values are found first by skipping 52192 bytes into the file, then reading the next 59 values. The time values are stored similarly at 181676 bytes from the beginning of the file in a set of 59, 4-byte floats.
I'm able to plot each of these sets by themselves against the coordinate number, but I'm not able to plot the data versus the time. Here are the two lines that work as I would expect:
plot 'file.bin' binary endian=big record=59 skip=52192 using 1 title "data-1" with lines
plot 'file.bin' binary endian=big record=59 skip=181676 using 1 title "time-1" with lines
Here is how I'm trying to plot data-1 versus time-1 (the 129248 skip value is 181676-52192+4(59)):
plot 'file.bin' binary endian=big record=59:59 skip=52192:129248 using 2:1 title "data vs time" with lines
However, this seems to concatenate the two records into the 1 column, rather than storing the first record in column 1 and the second in column 2. I'm not sure how to prevent this concatenation.
I've read Plotting 1D binary array, but it ultimately plots against the coordinate values instead of plotting the first record against the second.
Related
can you please help me by telling how to plot line graph in python(python 3.x preferably) using two lists containing string values.
my lists looks like:
y= ['27%', '27%', '27%', '27%', '27%', '27%', '27%']
x= ['18ww25', '18ww27', '18ww28', '18ww28.1', '18ww29', '18ww29.1', '18ww29.2']
moreover, there are multiple such pairs with different y list but same x list. Moreover x list should form markers on the X axis.
Moreover I am extracting these values from an excel file using pandas because of which I am getting values like "18ww28.1" although in excel file it is present as "18ww28"
how to plot a single graph containing all the lines from such pairs by correcting all x list values(for eg from "18ww28.1" to "18ww28") and then plotting.
If 7 pairs are there then the 7 lines should be there in graph and y list values should be plotted in the same format(in percentage)
the table which i want to plot is- excel table
actually, this file originally conatins many tables. I have read the complete file in a pandas data frame then grouped this table then converted this table to csv and then iterated through each row by storing each row value to a list and have also stored 1st row value in a list and want to plot each row list against first row list in such a way-
row1_list=['18ww24','18ww25','18ww34'](for ex)
row2_list=['24%','25%','67%'](for example)
This basically means consumption of some resource is '24%' on '18ww24' thats why I have to plot ('18ww24','24') as a point in graph(same for all the corresponding values of both the list)
then similarily,
row1_list
row3_list
and so on for every row......
Also, 1st row should form markers on X axis against which every entry of other rows are plotted and the plotted line for each row should be on same graph
I have a 3 column table named 'A' from which I want to plot a heatmap or scatter plot where I can see a colour for the coordinates indicated by the first two columns. For example, at row 'A91552' and column 's_4_AAGCTA' I want to see a colour corresponding to 0.47619.
Example data:
'A91552' 's_4_AAGCTA' 0.476190000000000
'A91554' 's_4_CCTATT' 0.476190000000000
's_4_AAGCTA' 'A91552' 0.476190000000000
's_4_CCTATT' 'A91554' 0.476190000000000
Is there a way to do this directly using the strings as indices, or will I need to make a double matrix and change the axis labels on something like imagesc?
Found it:
I just needed to convert my lists of strings to categorical variables:
scatter(categorical(A.Var1), categorical(A.Var2), 125, A.Var3, 'filled')
I have some values given by clock time, where the first column is the time. However, the values until 2 o clock still belong to the current day. Given
3 1
12 4
18 1
21 2
1 3
2 0
named as test.data, I'd like to print this in gnuplot:
set xrange [0:24]
plot 'test.data' with lines
However, the plot contains a backward line. It's striking through the whole diagram.
Is there a way to tell gnuplot to explicitly not print such backward lines, or even better, print them wrapping around the x axis (e.g. in my example drawing the line as a forward line up to 24, and then continuing it at 0)?
Note: The x axis of the plot should still start at 0 and end at 24.
As far as wrapping over the edge of the graph (a pac-man like effect), gnuplot can't do that on it's own. Even doing it manually, you would have to somehow calculate the right point to re-enter the graph based on the slope of the connecting line, and insert a new point into the data to control where the re-entry line enters, and where the exiting line exits. This would require external processing.
If you can do some outside preprocessing, adding a blank line before the 1 3 line will insert a discontinuity into the plot and prevent gnuplot from connecting those points (see help datafile for how gnuplot handles blank lines). Of course, you could always sort the data too.
I would recommend sorting the data before plotting, but if you do want to do this wrapping effect, the following python program (wrapper.py) will set up the data for it
data = [tuple(map(float,x.strip().split(" "))) for x in open("data.txt","r")]
data2 = sorted(data)
back_in_to = data2[0]
out_from = data2[-1]
xdelta = back_in_to[0] + 24 - out_from[0]
ydelta = back_in_to[1] - out_from[1]
slope = ydelta/xdelta
outy = out_from[1] + (24-out_from[0])*slope
print(0,outy)
for x in data2:
print(*x)
if x[0]==data[-1][0]: print("")
print(24,outy)
It reads in the data (assumed to be in data.txt, and calculates the points where a line should leave the graph and where it should re-enter, adding these points to the sorted data. It adds a blank line after the last point in the original graph, causing the break in the line. We can then plot like
plot "< wrapper.py" with lines
If we look at your original plot
we see the backward line that you referred to which reaches from the furthest right point to the next left point. The plot that the python program pre-processed reaches through the right of the graph to move back to this point.
I want to create an automated scatter plot. This is the first example table based on the step size I end up measuring A, B, C, D for a specific frequency. In this scatter plot I created manually you can see I want to plot C v/s A for a particular frequency.
But I need to do this automatically as based on the step size the number of row can change. Here, since the step size decreased the number of samples increased, and now the scatter plot needs to update number of A and C values it plots.
Is there a formula I can use without using any macros?
The relation between the step size and frequency is (number of samples of a single frequency = (360/step size)) so for a step size of 60 you will have in reality six entries of frequency 100 and six of 200 .
You can use formulas to define chart ranges if you hide the formulas in named ranges. Combine that with the fact that #N/A values are not plotted and you can get this to work without VBA.
For your example graph you could define two names ranges as follows:
Name: A_100
Refers To: =IF(Sheet1!$E$3:$E$100=100,OFFSET(Sheet1!$A$3,0,0,360/Sheet1!$B$1,1),NA())
and
Name: C_100
Refers To: =IF(Sheet1!$E$3:$E$100=100,OFFSET(Sheet1!$C$3,0,0,360/Sheet1!$B$1,1),NA())
Then set the X and Y axis of the chart to SheetName!A_100 and SheetName!C_100
The if statement filters out all the points not at frequency 100, if you have a formula for selecting the frequency replace "Sheet1!$E$3:$E$100=100" with that.
The offset function takes the first cell in the column and expands the number of rows according to your 360/step size formula.
My data file is a set of sorted single-column:
1
1
2
2
2
3
...
999
1000
1000
I am able to successfully plot the CDF using the command like (assuming 10000 lines in the file):
plot "file" using 1:(1/10000.) smooth cumulative title "CDF"
I am also able to plot the logcale of x axis by:
set logscale x
My problem is how can I have a CCDF plotting with Gnuplot?
In additional, the CDF with log-log scale (set logscale xy) can not give me any output. What if I would like to have a log-log CCDF plotting?
Many thanks!
I found a workaround for this problem, because I do not think you can plot a CCDF only using gnuplot.
Briefly, I just parsed my data using bash to create a dataset where the cumulative data is explicit; then gnuplot may simply plot the new dataset. As an example, assuming that your file contains the (numerical) values you want to cumulate, I would do in a bash environment:
cat data | sort -n | uniq --count | awk 'BEGIN{sum=0}{print $2,$1,sum; sum=sum+$1}' > parsed.dat'
This command reads the dataset (cat data), sorts the numerical data using their value (sort -n), counts the occurrences of each sample (uniq --count) and creates a new dataset, calculating as well the cumulative sum of each data value (the awk command).
This new dataset contains 3 columns: the first column ($1 in gnuplot) contains the unique values of your dataset, the $2 contains the number of the occurrences of your values, and the third column represents the cumulative sum.
Finally, in gnuplot, you can do this:
stats "parsed.dat" using 3;
plot "parsed.dat" using 1:($3/STATS_max) with lines title "CDF",\
"" using 1:(1-$3/STATS_max) with lines title "CCDF",\
"" using 1:($2/STATS_max) with boxes title "PDF"
The stats command of gnuplot analyzes the third column (the one with the cumulative sum) and stores the values to some variables. STATS_max is the max value of this column (so it is the final cumulative sum). Now you have all the data you need to plot not only the CDF, but also the CCDF (which is 1 - CDF) and also the PDF (or the normalized histogram, for discrete values).