Issue
I am using pcolormesh to create a heatmap.
heatmap = plt.pcolormesh(
grid,
edgecolors="k",
cmap=colors.ListedColormap(
[
"white",
"red",
"blue",
"green",
"orange",
"black",
"purple",
"yellow",
"brown",
"violet",
"gray",
]
),
linewidth=2,
)
ax = plt.gca()
ax.set_aspect("auto")
I want to set the cells shape to be rectangular. How can I do that?
Solution
I imagine you meant "square" cells, not "rectangular":
Set aspect to 1: ax.set_aspect(1)
aspect defines the Y/X ratio, so to have twice as high cells: ax.set_aspect(2)
And twice as wide: ax.set_aspect(1/2)
Answered By - mozway
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.