here is the sample code for drawing a single axis in a figure.

import matplotlib.pyplot as plt, numpy as np, os

figure = plt.figure()

sample_size = 500
x_arr = np.random.rand(sample_size)
y_arr = np.random.rand(sample_size)

# since x,y range is 0~1, create bin for x and y with space of 0.05.
# this bin will be used for both x and y axis in this example.

space = 0.05
common_bin_arr = np.arange(0,1+space*0.5, space)

plt.hist2d(x_arr, y_arr, bins=common_bin_arr)

outputdir = 'testoutput/t1'
if not os.path.exists(outputdir):
savepath = os.path.join(outputdir, 'save.png')

The above is the result.

I have tried to create several subplots and add heatmap to each one with individual colorbars on its side, but it seems this is hard to implement.


Leave a Reply

Your email address will not be published.