1

How can I plot an x vs y graph in gnuplot.py? For example, this is what I want: http://www.mathwarehouse.com//graphs/distance-vs-time/images/distance-vs-time-graph-picture4.jpg

I want multiple lines.

My code:

import Gnuplot

g = Gnuplot.Gnuplot(debug=1)
g.title('A simple example') # (optional)
g('set data style linespoints') # give gnuplot an arbitrary command
g.title('Data can be computed by python or gnuplot')
g.xlabel('x')
g.ylabel('y')
one = ([0, 1], [2, 3], [5, 5])
g.plot(one)
raw_input()

Output: http://gyazo.com/ba9fb6d6762c864758a7b494d44d384f

Only has one line. If I try to plot another, nothing will happen.

2 Answers 2

2

Just add other data sets in you code

two=([6,4], [7,5], [8,3])
three=([0,2], [2,1], [5,6], [6,5], [7,7], [8,4])

and finally plot the three data sets by

g.plot(one, two, three)

Here is my output: enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

In the newer versions (>4.4?) of gnuplot, if you use:

g('set data style linespoints') 

like in the original post, you'll get an error:

line 0: Unrecognized option. See 'help set'.

In stead, use:

g('set style data lines')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.