The Community for Data Integration is doing a third installment of experimenting with group learning with online platforms.
We have done an introductory course to Git, and introductory course to python, and now are moving on to some plotting in python.
"Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms."
Knowing that it's hard to self-motivate to finish an entire online course, let's do it together with a peer group and a set deadline!
What: DataCamp: Selected Matplotlib materials: (1) interactive chapter, (2) tutorial, (3) cheat sheet.
Background info: Matplotlib gallery, Documentation
Where: Online at the links above.
When: Between December 3 and December 19, 2018 (approximate 3 hour commitment)
Who: You, and Leslie, and peers from the Community for Data Integration.
How:
Questions? Send them to lhsu@usgs.gov or post them here. (You must be a CDI member and signed in to post a comment here. Email cdi@usgs.gov to become a member.)
7 Comments
Hsu, Leslie
Hi all - hope many of you have had a chance to delve into the first week's exercise of the interactive DataCamp chapter on matplotlib. Here are some of my thoughts:
Here is a plot of CDI funded project outputs (2010-2016) by deliverable type - the number delivered and the number still accessible online now. I still have some improvements to make, but given that I just started matplotlib-ing one week ago, I'll say it's not a bad start.
Langseth, Madison Lee
I'm a little behind and just finished the first exercise. Matplotlib seems like a fairly easy library to use. I've always kind of fumbled through making visualizations in python and never knew which library would be best. For example, after I finished the exercise, I went and looked at a Jupyter Notebook that I created to visualize data release metrics. In that notebook, I import both matplotlib and plotly, but I only end up using plotly (clearly I follow best practices in my notebooks...). I'm trying to remember why I decided to use plotly as opposed to matplotlib, but I can't recall. Does anyone have a strong preference in vis libraries and, if so, why?
Hsu, Leslie
I've thought of Plotly as being more evolved/mainstream and having more interactive capabilities - something that produces nice-looking plots that might appear in a blog or online journalism. Meanwhile, I think of Matplotlib as more staid, for scientific manuscripts. Maybe that is not a good distinction to make!
Hsu, Leslie
The blog post I read in week 3 addresses some of the different options:
...Also, many of the advanced python packages like seaborn and ggplot rely on matplotlib so understanding the basics will make those more powerful frameworks much easier to learn.
Finally, I am not saying that you should avoid the other good options like ggplot (aka ggpy), bokeh, plotly or altair. I just think you’ll need a basic understanding of matplotlib + pandas + seaborn to start. Once you understand the basic visualization stack, you can explore the other options and make informed choices based on your needs.
Hsu, Leslie
Week 2: Notes on the Matplotlib Tutorial
https://www.datacamp.com/community/tutorials/matplotlib-tutorial-python
I appreciated the comprehensiveness of the tutorial, starting from the anatomy of a Matplotlib plot going all the way to closing and saving out the plots. But also, the many external links (and links to links) show that this tutorial has only scratched the surface.
Some of this week’s thoughts:
Something I read on a link out mentions that there are two plotting styles - Pyplot vs. the object-oriented API - and that this often confuses beginners. Yes. The link out mentions that the official Matplotlib documentation recommends the object-oriented API style. Ok. I guess I will just need to forget the Pyplot things that I just learned.
Looks like Matplotlib’s official tutorial page is a good place to get more into depth on certain topics.
The tutorial mentions Artist objects, and a web search led to this page, which I found informative (and also somewhat overwhelming) https://dev.to/skotaro/artist-in-matplotlib---something-i-wanted-to-know-before-spending-tremendous-hours-on-googling-how-tos--31oo
I’m tempted to learn more about changing the default matplotlibrc settings, but then also worry that if I give someone some code to make a figure, it won’t be the same on their computer.
In an ideal world, I would have completely internalized the anatomy of the plot and how to call and manipulate parts of the figure. Even though this gave a good overview, I know that a lot of web searching is going to happen in the future to find specific snippets.
Conclusion: I think I have enough info to be dangerous with Matplotlib. Has the information in the materials we've reviewed been helpful for others?
Strange, Jayme M
I went through this tutorial rather quickly but got lost in all the material in the external links. Therefore, I am completing most of this today (beginning of week 3).
Few things that I liked:
The information in the material has been helpful! Starting to feel comfortable already.
Hsu, Leslie
Week 3: Matplotlib: The Lifecycle of a Plot tutorial
This tutorial (at https://matplotlib.org/tutorials/introductory/lifecycle.html#sphx-glr-tutorials-introductory-lifecycle-py) states that it is based off of a blog post, http://pbpython.com/effective-matplotlib.html, so I read that first. Reading the blog post and then tutorial really helped to re-emphasize the concepts learned in the past two weeks. I suggest that you do so!
A lot of things were explained very clearly, but here are a couple of questions:
1. Both the blog and tutorial repeat that one should try to use the object-oriented interface over the pyplot interface. So why, in the first code block, are we doing
import matplotlib.pyplot as plt
Is this not using the pyplot interface? Confusion remains...
2. I have missed something in the syntax of, for example, figure.Figure.savefig(). The tutorial says, "We can then use the figure.Figure.savefig() …"
then in the code block it is simply fig.savefig.
I need a little explanation of where all the prefixes come from, and why the abbreviation is okay.
Well that's it - three weeks of Matplotlib! Hope you have some new plotting options!