Discussion:
[Tutor] Plotting with python
Terry Carroll
2015-10-31 00:00:52 UTC
Permalink
If you were going to get started doing some simple plotting with Python
2.7 (in my case, I'm simply plotting temperature against time-of-day) what
would you use?

- matplotlib [1]
- gnuplot [2]
- something else entirely?


Assume no substantial familiarity with the underlying plotting software,
let alone the Python bindings.

The only thing I can think of that might be special is to specify the
upper/lower bounds of the plot; for example, in my case, I know the
temperatures vary between somewhere around 70-78 degrees F., so I'd want
the Y-axis to go, say 60-90, not arbitrarily start at zero; but I suspect
this is a pretty standard thing in almost any plotting package.

[1] http://matplotlib.org/api/pyplot_api.html
[2] http://gnuplot-py.sourceforge.net/
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-10-31 02:24:45 UTC
Permalink
Post by Terry Carroll
If you were going to get started doing some simple plotting with Python
2.7 (in my case, I'm simply plotting temperature against time-of-day)
what would you use?
- matplotlib [1]
- gnuplot [2]
- something else entirely?
Assume no substantial familiarity with the underlying plotting software,
let alone the Python bindings.
The only thing I can think of that might be special is to specify the
upper/lower bounds of the plot; for example, in my case, I know the
temperatures vary between somewhere around 70-78 degrees F., so I'd want
the Y-axis to go, say 60-90, not arbitrarily start at zero; but I
suspect this is a pretty standard thing in almost any plotting package.
[1] http://matplotlib.org/api/pyplot_api.html
[2] http://gnuplot-py.sourceforge.net/
matplotlib, I gave up gnuplot in favour of it maybe 15 years ago and
have never looked back.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Martin A. Brown
2015-10-31 05:57:39 UTC
Permalink
Post by Terry Carroll
If you were going to get started doing some simple plotting with Python
2.7 (in my case, I'm simply plotting temperature against time-of-day)
what would you use?
- matplotlib [1]
- gnuplot [2]
- something else entirely?
Assume no substantial familiarity with the underlying plotting software,
let alone the Python bindings.
The only thing I can think of that might be special is to specify the
upper/lower bounds of the plot; for example, in my case, I know the
temperatures vary between somewhere around 70-78 degrees F., so I'd want
the Y-axis to go, say 60-90, not arbitrarily start at zero; but I
suspect this is a pretty standard thing in almost any plotting package.
[1] http://matplotlib.org/api/pyplot_api.html
[2] http://gnuplot-py.sourceforge.net/
matplotlib, I gave up gnuplot in favour of it maybe 15 years ago and have never
looked back.
I think my transition was later and I'm modestly bilingual with
these tools. However, in principle, I agree with Mark--IF you are
primarily using Python as your tool for massaging and exploring
data.

If you are, then I might add one more suggestion. There's a project
called 'IPython' [0] which has built a very nicely extended and
richer interactive interface to the Python interpreter. You can use
IPython as a replacement for the Python interactive shell. I have
for years, and it's wonderful (even though, I also use the
interactive shell that ships with the system supplied Python I use).

Why am I talking about IPython? Aside from other benefits, the
IPython Notebook [1] is directly useful to those who are also
matplotlib users, because it allows you to record an entire analysis
session, display graphics inline (see macro "%matplotlib inline")
and then later, share the data explorations in a web browser.

N.B. I have not found any running, public IPython Notebooks. This
doesn't surprise me, because of the security risks of allowing just
anybody access to a Python instance is like letting strangers into
your kitchen. They might eat all of your food, or try to crack that
safe behind the portrait in the dining room.

http://calebmadrigal.com/graph-ipython-notebook/

So, if I were in your shoes, starting today, I'd install IPython and
matplotlib and then fire up the IPython Notebook on my local
machine, type '%matplotlib inline' and start trying to display my
data. One nice feature of matplotlib is that it autoscales by
default. So, if all of your values (temperature) are within the
range you want to display, you don't need to mess with the axes.

See their tutorial:

http://matplotlib.org/users/pyplot_tutorial.html

Good luck and enjoy!

-Martin

[0] http://ipython.org/
[1] http://ipython.org/notebook.html
--
Martin A. Brown
http://linux-ip.net/
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Laura Creighton
2015-10-31 06:33:23 UTC
Permalink
I'd use matplotlib, unless the ultimate goal is to render onto a
webpage. Then I would use bokeh.

http://bokeh.pydata.org/en/latest/

Laura
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Oscar Benjamin
2015-11-03 15:37:34 UTC
Permalink
If you were going to get started doing some simple plotting with Python 2.7
(in my case, I'm simply plotting temperature against time-of-day) what would
you use?
- matplotlib [1]
- gnuplot [2]
- something else entirely?
I'd use matplotlib.
Assume no substantial familiarity with the underlying plotting software, let
alone the Python bindings.
The only thing I can think of that might be special is to specify the
upper/lower bounds of the plot; for example, in my case, I know the
temperatures vary between somewhere around 70-78 degrees F., so I'd want the
Y-axis to go, say 60-90, not arbitrarily start at zero; but I suspect this
is a pretty standard thing in almost any plotting package.
This is straightforward in most plotting packages. Here's a simple
example of doing it in matplotlib:

#!/usr/bin/env python3

import matplotlib.pyplot as plt

times = [0, 1, 2, 3, 4, 5] # hours
temperatures = [68, 70, 75, 73, 72, 71] # Fahrenheit

fig = plt.figure(figsize=(5, 4))
ax = fig.add_axes([0.15, 0.15, 0.70, 0.70])
ax.plot(times, temperatures)
ax.set_xlabel('Time (hours)')
ax.set_ylabel(r'Temp ($^{\circ}\mathrm{F}$)')
ax.set_title('Temperature vs time')

plt.show()

--
Oscar
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Loading...