On 31 October 2015 at 00:00, Terry Carroll <carr...@tjc.com> wrote:
> 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  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to