Closed 153957 closed 8 years ago
See page 261 of the PGFPlots manual:
you can also set point meta min and point meta max manually in order to draw a colorbar.
These values can be set using the mlimits
in artist, which are used to limit the color range for scatter_table
plots. This can be used to 'manually' make a colorbar for histogram2d in artist using:
plot = Plot()
x = random.normal(0, 10, 10000)
y = random.uniform(0, 1, 10000)
counts, xbins, ybins = np.histogram2d(x, y, 25)
plot.histogram2d(counts, xbins, ybins)
plot.set_mlimits(counts.min(), counts.max())
plot.set_colorbar()
plot.set_colormap('blackwhite')
plots.save_as_pdf('histogram2d_colorbar')
Agreed, would be very nice!
It works, but not for multiplots, or multiple histogram2d plots in a single plot. This is because the mlimits (min/max counts in a bin) might differ between plots, this is not accounted for when making multiple plots. For each histogram2d the min/max colors are scaled between the min/max values for that plot.
Great! Sometimes I think we should drop pgfplots and just use TikZ. More work, but more control.
The main problem with that is the 'more work' part.. (#4)
Mostly implemented in ea83fb9aba878bc9c9e1a424eb967cab29bf9c6d
Nice, thanks!
It would be nice to have colorbar support for 2D histograms.. There is a colorbar support for the
scatter_table
method, but not yet forhistogram2d
.