0

I created a heatmap plot (using seaborn) in PyQT5 with first parameters. When changing parameters to create new heatmap plot in this canvas with new values but ex color bar not remove like this:

enter image description here

I indeed need only one color bar for plot that day (cbar=True). I don't want fix vmin, vmax for all plot with difference data values.

sns.heatmap(df_grid, annot=False, cmap='tab20', ax=self.axes_surface, cbar=True)

How to remove the ex color bar in this case?

1

1 Answer 1

0

You don't provide a lot of code. Here is a general way:

At the start of the program your create an ax for the main plot, and another one for the colorbar. width_ratios can help to have the colorbar occupy much less space than the main heatmap.

my_fig, (my_ax, my_cbar_ax) = plt.subplots(ncols=2, figsize=(8, 6),
                                           gridspec_kw={'width_ratios': [10, 1]})

Inside the update function you provide both axes to sns.heatmap. If you don't provide the cbar_ax, seaborn will create a new colorbar every time you call your update function.

sns.heatmap(...., ax=my_ax, cbar_ax=my_cbar_ax)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.