Skip to end of metadata
Go to start of metadata

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:

  1. Sign up with your email on the list at https://goo.gl/uYMB3T (Feel free to sign up after the first week, you can still complete the course because it is at your own pace.)
  2. Every Monday from December 3 - December 17, 2018, you'll get a reminder to do the next section.
  3. As she completes the tasks, Leslie will post her progress, any questions or comments she had (as comments on this wiki page), and will encourage you to do the same.
  4. We will all complete the module before the new year and celebrate in our new Matplotlib knowledge.


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.)



  • No labels

7 Comments

  1. 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:

    • I really enjoyed this chapter, it had many examples and gave a good foundation for my future "googling" of how to do things. 
    • Why did they make the name similar to MATLAB? It confuses people (me). However, on wikipedia, it does say "Matplotlib is designed to be as usable as MATLAB, with the ability to use Python, and the advantage of being free and open-source."
    • Why am I so interested in learning matplotlib? It bills itself as a tool that "produces publication quality figures in a variety of hardcopy formats" and I would love to be able to do that in a reproducible, script-driven way. (Sorry, google spreadsheets, I am reluctant to include your plots in official reports.)
    • In order to experiment on my own, as I learned this past summer during the Python for Data Management course, I just fired up the Jupyter Notebook that comes with the Metadata Wizard 2, started a new folder, started making new notebooks and plots. It worked!

    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.




  2. 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?

    1. 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!

      1. 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.

  3. 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:

    1. 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.

    2. Looks like Matplotlib’s official tutorial page is a good place to get more into depth on certain topics.

    3. 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

    4. 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.

    5. 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.

    6. 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?

    1. 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:

      1. Breakdown of Pyplot vs. the object-oriented API - good information on keeping up with the Python "industry"
      2. plt.style.use("ggplot") - very nifty

      The information in the material has been helpful! Starting to feel comfortable already.

  4. Week 3: Matplotlib: The Lifecycle of a Plot tutorial

    This tutorial (at https://matplotlib.org/tutorials/introductory/lifecycle.html#sphx-glr-tutorials-introductory-lifecycle-pystates 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!