[melbourne-pug] Multi-line subplots

paul sorenson news02 at metrak.com
Fri May 27 02:00:25 EDT 2016


Kevin,

If you want multiple plots (the 3-4 stations in your question?) in your
matplotlib output you provide that to the matplotlib.pyplot.subplots()
function.  To draw multiple lines on a single plot you just call as many
plotting commands on each of the axis objects returned from the
subplots() call above.  If you want to plot "directly" from pandas IIRC
you want to put each of your time series in its own column.  There are
packages such as seaborn that have functions specifically for plotting
time series.

There are stacks of examples over on the matplotlib and pandas - have
you checked the gallery pages for something that looks kind of like what
you want?

Once you figure out the plotting strategy - you get your dataframe into
the shape you need as appropriate.  set_index(), stack(), unstack(),
groupby() and pivot functions are your friend.

cheers

On 05/26/2016 05:20 PM, Nicholas Mellor wrote:
>
> Hi Kevin,
>
>  
>
> What’s the plotting software you’re using?
>
>  
>
> Nick
>
>  
>
> *From:*melbourne-pug
> [mailto:melbourne-pug-bounces+nicholas.mellor=medibank.com.au at python.org]*On
> Behalf Of *Kevin Shackleton
> *Sent:* Thursday, 26 May 2016 10:56 PM
> *To:* Melbourne Python Users Group <melbourne-pug at python.org>
> *Subject:* [melbourne-pug] Multi-line subplots
>
>  
>
> Hi All,
>
> I am making heavy going of what should be quite concise code.
>
> I monitor messages (about 30 sorts) coming from several (3 or 4)
> stations.  I make a count of the messages per station per day, going
> back 30 days (0, -1, -2 . .), like this:
>
> Message  Station  Day  Count
>
> A               A          0      5
>
> A               A          -1     2
> A               B          0     13
> A               B          -1     3
> A               C          0      2
>
> A               C          -1     2
> B               A          0      1
> B               A          -1    21
> B               B          0     18
> B               B          -1    34
> B               C          0       7
>
> B               C          -1    38
> C               A  etc . .
>
> To make it quick and easy for the operating staff to review the site
> status, I want to make about 30 plots (in a single column on the
> canvas), each with the X axis going from -30 to 0 days, Y axis of
> Count and 3 or 4 lines showing the message count for each station.
>
> I'm having trouble finding how to subplot the graph page and print
> multiple lines in each sub-plot.
>
> There is also the need to fill in missing values to not misrepresent
> having zero messages for a message/station/day, consequently I was
> trying to run the data via a pivot_table(fill_value=0).
>
> A clue or reference would be greatly appreciated,
>
> Regards,
>
> Kevin.
>
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>
>
> _______________________________________________
> melbourne-pug mailing list
> melbourne-pug at python.org
> https://mail.python.org/mailman/listinfo/melbourne-pug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/melbourne-pug/attachments/20160526/066d5577/attachment-0001.html>


More information about the melbourne-pug mailing list