colorbar

Adjusting colorbar legend limits

Adjusting colorbar legend limits Question: I have the following python code to plot a surface contour plot: import matplotlib.pyplot as plt from matplotlib import cm import pandas as pd dx = {‘1’: 1, ‘2’: -1, ‘3’: -1, ‘4’: 1, ‘5’: 0} x = pd.Series(data=dx, index=[‘1’, ‘2’, ‘3’, ‘4’, ‘5’]) dy = {‘1’: 1, ‘2’: 1, …

Total answers: 1

how to add a colorbar to a plot

how to add a colorbar to a plot Question: i have a dataframe with two columns The one is dif and the other is sza i have made the following scatter plot x = df[‘sza’] y = df[‘dif’] # Calculate the point density xy = np.vstack([x,y]) z = gaussian_kde(xy)(xy) fig, ax = plt.subplots() ax.scatter(x, y, …

Total answers: 1

Setting custom ticks on a colorbar adds white bands to the ends

Setting custom ticks on a colorbar adds white bands to the ends Question: I’m creating a plot with my data and using colorbar to represent the values. My data don’t have 0, 1 and 4. However, I want the colorbar to start from 0 and go up to 4. By default, I get the below …

Total answers: 1

Issue with colorbar and imshow with gridspec

Issue with colorbar and imshow with gridspec Question: I wanted to plot 2 imshow on a figure, but I only want the sub figure on the right to have the colorbar at the bottom of its plot. import matplotlib.pyplot as plt import numpy as np from matplotlib.gridspec import GridSpec cm = 1/2.54 fig = plt.figure() …

Total answers: 1

How do I match the size of my colorbar with the subplots?

How do I match the size of my colorbar with the subplots? Question: I am trying to add one single colorbar to all my 4 subplots, I have gone through a lot of answers but the codes over there appear confusing to me and I am new to python and matplotlib The code I have …

Total answers: 1

transform colors in colorbar, not the ticks

transform colors in colorbar, not the ticks Question: When using a custom normalization, for instance PowerNorm, we can adjust the mapping between values and the colors. If we then show a corresponding colorbar, we can see the change when observing the ticks (compare left and right plot in the following picture). Is there a way …

Total answers: 1

Colorbar and its range shared between two plots

Colorbar and its range shared between two plots Question: I adapted this code (https://stackoverflow.com/a/73099652/2369957) that demonstrates how to share a colorbar and its range for two plots, but it doesn’t seem to work when the range of the two plots are different – in the case of the posted code, the plots have the same …

Total answers: 1

Generating just a colorbar with labels

Generating just a colorbar with labels Question: I’m trying to generate just a colorbar in matplotlib to go with a series of clustermaps, following this guide. Here is my current code: fig, ax = plt.subplots(figsize=(3,8)) cmap = mpl.cm.inferno bounds = [0,1,2,3,4,5] norm = mpl.colors.BoundaryNorm(bounds, cmap.N) fig.colorbar( mpl.cm.ScalarMappable(cmap=cmap, norm=norm), ticks=[0.5,1.5,2.5,3.5,4.5], # labels=["A", "B", "C", "D", "E"], …

Total answers: 2

How to adjust Plotly legend/colorbar background transparency/colour

How to adjust Plotly legend/colorbar background transparency/colour Question: I’m trying to edit the appearance of a map I have made, but if I choose to have the colorbar/legend visible, it sits on a white background: This white is a bit jarring for the rest of the color scheme. At the moment, I’m just hiding the …

Total answers: 1

How to remove spaces between multiple colorbars in one figure with matplotlib?

How to remove spaces between multiple colorbars in one figure Question: I am trying to plot three colorbars horizontally. I would like to remove the white spaces between the three colorbars. Is there a way to do this and/or to gradually adjust the space? Code for reproduction: import matplotlib as mpl import matplotlib.pyplot as plt …

Total answers: 1