Plotting graphs with error ribbons in python - python

for a while I've been trying to come up with a good way to graphically represent a data series along with its estimated error.
Recently I saw some graphs where the data was plotted as a line, with a background 'ribbon' filling the area between the lines plotting data +/- sigma.
Is there a name for this type of graph, and is there any python toolkit which has the capability to make such plots?
A simple way to fake it with matplotlib would also be useful - right now I'm just plotting three lines, but I don't know how to fill the area between them.

I would use the fill_between method. Look at the Our Favorite Recipes section of the manual for matplotlib for some good examples. They have one that looks like this:
and another that looks like this:

Related

How do I plot a scatterplot with marginal histograms AND histogram of differences using matplotlib and/or seaborn?

I'm looking to augment my scatterplot (Python code, using Matplotlib and/or Seaborn) with marginal distributions (here plotted as histograms, but could also be kernel density estimates):
with a visualization of the differences (histogram/density estimate), like so:
I could probably roll my own, but this seems like such a common use case that I'm suspecting this might be implemented somewhere already in Matplotlib or Seaborn. A good fifteen minutes of Googling did not yield anything, and it also has not been asked before here on StackOverflow. Does anyone know of an off-the-shelf solution for this? (If no one does, I'll write my own and post it of course.) Thanks!

Stacked heatmaps - seaborn solution?

EDIT: For some reason I've been downvoted twice for posting this question (it hurts ppl) so I've rejigged it.
How do you combine multiple heatmaps in a stacked way with same color scale like to following image?
Additionally, does anyone know how to create the Augmented suffix tree?
Background:
I've worked through the python jupyter notebooks at the following link on how to create the heatmaps of (any) daily consumption profiles using seaborn
http://www.datadrivenbuilding.org/
...however there's a realllllllly cool combination graphic I'd love to be able to reproduce.
That image is an edited version of an image from this paper:
C. Miller, Z. Nagy, A. Schlueter, Automated daily pattern filtering of
measured building performance data, Automation in Construction 49,
Part A (2015) 1–17. doi:10.1016/j.autcon.2014.09.004. URL
http://www.sciencedirect.com/science/article/pii/S0926580514002015
They came up with the visualisation techniques themselves and describe them there. It looks like C. Miller is the one who wrote the notebook that you already found that shows how to draw the stacked heatmaps.
The augmented suffix tree is a type of visualization called a Sankey Diagram. You can plot these very beautifully using Plotly for example, or pySankey if you want to use matplotlib.

Two violin plots (horizontal and vertical) intersecting at a point

I am unsure whether this functionality is possible through Plotly or if it is achievable with other plotting packages so I am open to different solutions.
I am trying to plot two violin plots in a single figure where one violin is oriented horizontally while the other is vertical. I would like to specify the point at which they intersect (i.e the primary axis of each). Ideally each would be transparent and interactive.
Somewhat poor illustration of what I need
Thank you for any proposed solutions!
There are multiple Python libraries doing Violin Plots. Plotly is among them, check its manual.
Besides, Seaborn is really good at this:
It is a Python visualization library based on Matplotlib. The code snipped for the above example can be found in Seaborn's gallery.

Best way to create a 2D Contour Map with Python

I am trying to create a 2D Contour Map in Python that looks like this:
In this case, it is a map of chemical concentration for a number of points on the map. But for the sake of simplicity, we could just say it's elevation.
I am given the map, in this case 562 by 404px. I am given a number of X & Y coordinates with the given value at that point. I am not given enough points to smoothly connect the line, and sometimes very few data points to draw from. It's my understanding that Spline plots should be used to smoothly connect the points.
I see that there are a number of libraries out there for Python which assist in creation of the contour maps similar to this.
Matplotlib's Pyplot Contour looks promising.
Numpy also looks to have some potential
But to me, I don't see a clear winner. I'm not really sure where to start, being new to this programming graphical data such as this.
So my question really is, what's the best library to use? Simpler would be preferred. Any insight you could provide that would help get me started the proper way would be fantastic.
Thank you.
In the numpy example that you show, the author is actually using Matplotlib. While there are several plotting libraries, Matplotlib is the most popular for simple 2D plots like this. I'd probably use that unless there is a compelling reason not to.
A general strategy would be to try to find something that looks like what you want in the Matplotlib example gallery and then modify the source code. Another good source of high quality Matplotlib examples that I like is:
http://astroml.github.com/book_figures/
Numpy is actually a N-dimensional array object, not a plotting package.
You don't need every pixel with data. Simply mask your data array. Matplotlib will automatically plot the area that it can and leave other area blank.
I was having this same question. I found that matplotlib has interpolation which can be used to smoothly connect discrete X-Y points.
See the following docs for what helped me through:
Matplotlib's matplotlib.tri.LinearTriInterpolator docs.
Matplotlib's Contour Plot of Irregularly Spaced Data example
How I used the above resources loading x, y, z points in from a CSV to make a topomap end-to-end

Fitted curve on chart using ReportLab

I'm preparing a set of reports using open source ReportLab. The reports contain a number of charts. Everything works well so far.
I've been asked to take a (working) bar chart that shows two series of data and overlay a fitted curve for each series.
I can see how I could overlay a segmented line on the bar graph by creating both a line chart and bar chart in the same ReportLab drawing. I can't find any reference for fitted curves in ReportLab, however.
Does anyone have any insight into plotting a fitted curve to a series of data in ReportLab or, failing that, a suggestion about how to accomplish this task (I'm thinking that chart would need to be produced in matplotlib instead)?
I would recommend using MatPlotLib. This is exactly the sort of thing it's designed to handle and it will be much easier than trying to piece together something in ReportLab alone, especially since you'll have to do all the calculation of the line on your own and figure out the details of how to draw it in just the right place. MatPlotLib integrates easily with ReportLab; I've used the combination several times with great results.

Categories