-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
To help us understand and resolve your issue please check that you have provided
the information below.
- Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
- How did you install Matplotlib and Python (pip, anaconda, from source ...)
- If possible please supply a Short, Self Contained, Correct, Example
that demonstrates the issue i.e a small piece of code which reproduces the issue
and can be run with out any other (or as few as possible) external dependencies. - If this is an image generation bug attach a screenshot demonstrating the issue.
- If this is a regression (Used to work in an earlier version of Matplotlib), please
note where it used to work.
matplotlib ver 1.5.3, python ver 2.7, linux
installed by anaconda
I have a plot produced by imshow that shows how 30 samples switch between different classes (represented by integers) over time:
A simplified version of the code follows, Z is the dataset used to produce the plot.
import matplotlib.pyplot as plt
import matplotlib.colors as col
import palettable as ptbl
colmap = col.ListedColormap(ptbl.colorbrewer.qualitative.Set2_6.mpl_colors)
plt.imshow(Z,interpolation='none', cmap=colmap)
plt.colorbar()
I used a ListedColormap to represent the discrete nature of the data.
I have another dataset, plotted similarly, that represents essentially the probability of that being the correct class over time:
As the system gets more certain over time, you can see that the probability increases to the right of the plot up to 1. Naturally this data is continuously distributed so I used a linear colormap.
I would like to combine these two plots as follows: Use the probability dataset as a mask, perhaps in saturation or some other quantity, over the class evolution image. So 1 would still be green, 2 would still be orange, etc., but no matter what color, it would get more towards gray as the system becomes less certain. Is there an easy way to do this?
My current thinking is to simply add the probability to the class number, so e.g. 1.8 would be an 80% chance of class 1, and use a LinearSegmentedColormap with 6 regions, each going from 0 saturation to the normal saturation of that color. If this is the best approach, how would I define that colormap?
This seems quite complicated however, and I am wondering if there is another approach to defining a 2D colorspace to represent 4D data.