Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23189

Using matplotlib pcolormesh, how can I stop the drawn tiles from one row to be connected to the rows above and below?

$
0
0

I have individual x arrays for each intensity (Z) array. Which means that the intensity rows will not be stacked on top of each other. I do not want the tiles to "tilt" so they are connected to the row above and below, I just want them to be straight in the y direction and connected in the x direction. Thank you very much in advance!

Here is a dummy code:

import numpy as npimport matplotlib.pyplot as plty_values = np.array([0, 1, 2, 3, 4, 5], dtype=float)x_list = range(50, 70)x_values_list = []z_values_list = []for i in range(len(y_values)):    x_value_single_list = [np.array(0.01*x**2 + 0.1*x*i + 0.3 * i, dtype= float) for x in x_list]    x_values_list.append( x_value_single_list)    z_values_list.append(np.random.rand(20))z_values_list = [np.array(arr, dtype=float) for arr in z_values_list]x_values_list = [np.array(arr, dtype=float) for arr in x_values_list]fig, ax = plt.subplots()c = ax.pcolormesh(x_values_list, y_values, z_values_list, cmap='viridis') #, shading='auto'plt.colorbar(c)plt.show()

Image with tilted tiles

I have tried a bunch of kwargs but a lot of them does not seem to do anything and seem to not be implemented for pcolormesh and more suited for regular line plots. I have obviously tried a lot with ChatGPT.


Viewing all articles
Browse latest Browse all 23189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>