Results 1 to 4 of 4
I know its not that difficult graphing 2 things on one plot using gnuplot in linux but this seems like a unique situation that ive been trying to figure out ...
Enjoy an ad free experience by logging in. Not a member yet? Register.

 06192009 #1
 Join Date
 Jun 2009
 Location
 New York
 Posts
 12
Graphing 2 separate data files on one graph
I have 2 things I want to graph on the same chart; I have graphed them individually, but each time I graph them together I have issues.
1) I tried using multiplot and replot...with multiplot, they become graphed together but they each have their own scales overlapping on the x and y scales.. so my first question is how can I graph them together with only one x and y scale?
With replot, the second thing i graph becomes tiny because the scales are not right and I don't know how to fix them to accommodate both..any suggestions?
2)I tried writing a script which I then loaded in gnuplot, but it would not plot both..i believe it was because they have different x and y values although they fall on the same scale... is there anything other than replot and multiplot
This next part is a second issue that may make the first^ issue easier if I fix it:
The first thing to graph is pretty straightforward:
The first code for the first one is
plot [1:3] [12:19] "results1" 6:12 which I can successfully graph (its just 2 columns of a data file)
The problem is with the second thing I want to graph... maybe there's a better way to graph the second one to make replot or multiplot work, or use a simpler method:
Basically I want to graph something with the equation y=mx+b ... I have m and b as a constant # and x is one column of a data file (which I copied into its own). I tried a bunch of codes to graph this, but it didnt work so I took two values for x, plugged it in and got y and then made a datafile with hose 2 points and graphed that...the problem this causes is that the line is not extending beyond those points, which is why I am having issues with the scale so:
a) does anyone know a better code to graph y=mx+b, x being a bunch of points in a data file and y being unknown, or
b) if I keep it as two data points, does anyone know of a way to extend that line of that slope further beyond the 2 i have used?
i feel like the solution could be easy, its just I've tried multiple things each with its own problems so its now complicated.. thanks
 06192009 #2
 Join Date
 Apr 2009
 Location
 I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
 Posts
 11,957
This is an application issue, not a programming one. Please move this thread to the "Linux Applications" forum.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi  always be flexible!
 06212009 #3
Moved.
To discuss your questions, here is how I graph multiple things on one plot:
Code:plot "inv1.dat" notitle, "inv1.sup.dat" notitle linetype 1 pointtype 1 linecolor 1, bestfit(x) title 'Best Fit (0.0176x + 0.0089)' linetype 1 linecolor 2
For your second question, do you see how I graphed my function above? If you have a line, you don't have to tell it what data it uses: it will just use the xrange of the plot. If you want to create a best fit line, that's a different story (you give it the data that it should try to fit), but that doesn't seem to be the case here.
Does this help at all?
 06292009 #4
 Join Date
 Jun 2009
 Location
 New York
 Posts
 12
Sorry it took a while for a response...I don't know if I'm doing it wrong or what but I tried it and it is only graphing one thing... I did not put the best fit part in because I do not want a best fit line for all of the data..thanks anyway...i did get them both to plot with multiplot...but it shows two overlapped scales along the edges...how do you get rid of that...or how do you change the scales to fit both sets of data ( I tried several things that made no change...if youre code above will solve that problem then do you know what I could be doing wrong?).
Thanks