Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
41 views

Matplotlib: width of colorbar below a column of matshow

I have a column of matshow images and below the bottom one I want to place a colorbar with a width that is the same as that of the image(s). I tried following the suggestion of Set Matplotlib colorbar ...
Eduard Tetzlaff's user avatar
2 votes
0 answers
37 views

Contourf colourbar ticklabels are wrongly formatted with matplotlib 3.5.1 (python3)

I am trying to do contour plotting with the log scale for some data. And I seem to have run into an issue that I cannot find a solution for. When I use contourf plot and plot the colourbar in the log ...
vercors's user avatar
  • 21
1 vote
0 answers
65 views

How to create a custom color map [duplicate]

I need to create a custom cmap. I have made a dictionary of color and associated value from image: { 100: "RGB(170, 170, 170)", 75: "RGB(90, 0, 0)", 50: "RGB(180, ...
Samman Amgain's user avatar
2 votes
1 answer
37 views

Colormap of imshow not linked to surface_plot

I have created a figure with two subplots. On the left is a 3D surface plot and on the right side is 2D projection of the 3D plot with imshow. I want the colormap of the imshow plot to be linked to ...
sts's user avatar
  • 25
2 votes
1 answer
63 views

How to customize the caption text in Folium colorbar? I want to increase the font size of the colormap caption text

I am trying to use colorbar for an output variable circle plot in Folium colormap = cm.LinearColormap(colors=['green','red'], index=[min(df['output']), max(df['output'])], vmin=min(df['output']),vmax=...
Ajay Ganesh's user avatar
0 votes
1 answer
106 views

create discrete colorbar from colormap in python

I want to use a given colormap (let's say viridis) and create plots and colorbars with discrete colors from that colormap. I used to use mpl.cm.get_cmap("viridis", 7) for 7 different colors, ...
Therese's user avatar
  • 95
-1 votes
1 answer
52 views

show scale legend of 2D histplot

I want to add a color scale legend to a 2D seaborn dist plot that shows the frequency range of the color scale. An example is mocked up here in ms paint: I have looked around and seen many methods to ...
Null Salad's user avatar
0 votes
0 answers
31 views

When adding colorbars and legends to subplots, the colorbars are not properly sized

I've written some code to create subplots with maps based on the JRC Global Surface Water dataset. My code creates the maps just fine, but when I want to add a legend to explain the colors, they look ...
greasyfries's user avatar
1 vote
1 answer
52 views

plt.colorbar() isn't working as I expected

I'm sure that the issue is caused by the fact that my x linspace doesn't start from 0, since changing it to 0 fixes the problem (but breaks the plot). How can I fix this? I changed the linspace to 0 ...
Brian Ling's user avatar
0 votes
1 answer
23 views

how to animation with xarray dataset and cartopy projection with a colorbar?

How can I make an animation with xarray dataset which is projected on to a PlateCarree projection that includes a colorbar? I have spent some time trying to answer this question, and some other ...
dodohjk's user avatar
  • 198
0 votes
1 answer
54 views

Adjust Visual limits of colorbar legend in ggplot2 (R)

I want to represent the evolution of a variable (Observation) in the time. I want to color each point according to the value using the color code Everything works, no issue with the code. But, ...
Constantin Marguier's user avatar
2 votes
1 answer
62 views

Colorbar with custom LogNorm does not work properly

I modified LogNorm from matplotlib.colors such that the midpoint on the logscale can be set manually. The 2D colorplot changes accordingly with the new normalised colormap, but the colorbar stays the ...
TheDorkSide's user avatar
0 votes
0 answers
31 views

How can I add triangles to a ggplot2 colorbar in R to indicate out of bound values with ggproto?

This question was already posted and answered (https://stackoverflow.com/a/68442175/9827817). The code provided in the answer works perfectly. However, with the release of ggplot2 version 3.5.0, the ...
Riccardo's user avatar
0 votes
0 answers
22 views

How to plot two images of same shape in a plot, with one colorbar and still getting the images to be the same size?

I am trying to plot two satellite images next to eachother. The images is of the same area and have the same shape. One image is true color, and the other i have performed my analysis on. I want the ...
mankjo's user avatar
  • 11
0 votes
0 answers
16 views

Colorbar duplicates when moving the slider in a 3D surfaceplot with matplotlib in python

I have written code to make a 3D surfaceplot with sliders in Python. I also have a colorbar to better visualise what is happening. However, when I move a slider, the colorbar duplicates. How do I fix ...
Janiek Weening's user avatar
2 votes
1 answer
159 views

plotting a combined heatmap and clustermap, problems with adding two colorbars

I have two omics datasets which I woud like to compare. For this I plot one as a clustermap, and extract the order from it and plot the exact same genes as a heatmap, so that I can make a direct ...
WilkeM's user avatar
  • 33
0 votes
1 answer
98 views

How can I set the tick labels of my colorbar to a different color?

I am creating an image using the function below. Because I later want to integrate it into a window, I am changing the background color and as a result the text is not visible with the default color. ...
gunk's user avatar
  • 11
0 votes
1 answer
94 views

R plotly - Colorscale in colorbar is not the same as in plot

I have a scatter plot in R plotly where I want to color the markers on a fixed scale from 1 to 20, where 1 = dark green and 20 = dark red. Since this will be part of a Shiny app, I want to be able to ...
PoorYorick's user avatar
2 votes
2 answers
191 views

Creating a custom colorbar in matplotlib

How can I create a colorbar in matplotlib that looks like this: Here is what I tried: import matplotlib.pyplot as plt from matplotlib.colors import LinearSegmentedColormap from matplotlib.cm import ...
user308827's user avatar
  • 21.5k
0 votes
1 answer
36 views

Adding lines to colorbar in matplotlib that are longer than the colorbar

This is a follow-up question to Adding markers or lines to colorbar in matplotlib I would like to indicate positions on a colorbar that extends over the length/width of the colorbar itself. In the ...
Eduard Tetzlaff's user avatar
0 votes
1 answer
69 views

Matplotlib Colormap Normalization with Midpoint Value for Scatter Plot

I'm creating a scatter plot over a map using Matplotlib and Geopandas in Python, and I'm facing an issue with setting up my colorbar correctly. I want the maximum colorbar value to be 3.95 (...
Nico's user avatar
  • 1
0 votes
0 answers
19 views

cmap and color bar being compressed from the assigned range

This is a sample code. I want to build a heat map with values limited from 0.5 to 0.6, but with a linear color scale ranging [(0, 'yellow'), (0.25, 'orange'), (1, 'darkred')]. However, since there are ...
Anish Nahar's user avatar
0 votes
0 answers
8 views

Colorbar and contour plot seem to not match data; individual/custom scale to emphasize data of interest

I am trying to create a contour plot that shows the turbulence intensity of a measurement plane. However, towards the bottom the values are very high (about 45%) while the values are about 2-10% in ...
Selina Brinkmann's user avatar
1 vote
1 answer
43 views

Identical continuous color palettes in ggplot

I am trying to plot two graphs with the same continuous color palette. In one plot the range for the color palette to represent is 0-0.48 with the vast majority of points between 0-0.18. The other ...
awray's user avatar
  • 19
0 votes
1 answer
45 views

Matplotlib Heatmap with Discrete Custom Colorbar

I've been working on a plot where the data is composed of integers between 1 and 7 (inclusive). The plot is a heatmap and ideally I could associate whichever colour I want to any number. Accompanying ...
Félix Bélair's user avatar
1 vote
1 answer
37 views

Align ticks with matplotlib colorbar

I am trying to align the ticks on a colorbar with the discrete colors with little success. The following works but the ticks are not aligned with the colors. import matplotlib.pyplot as plt import ...
user90855's user avatar
  • 752
0 votes
1 answer
38 views

More than one color bar on plot

I am trying to plot three plots on one figure. Left two are just regular plots, but the top right one needs to be a correlation matrix with three additional colorbars, but I can't seem to get the ...
Jaka Kovše's user avatar
1 vote
2 answers
92 views

How do I set no "ticks" at all in the color bar?

I want to set the colorbar with no ticks in any form. I've searched and set the tick parameter at two places. However, still there are some ticks at right boarder. cb = mpl.colorbar.ColorbarBase(ax2, ...
an offer can't refuse's user avatar
0 votes
0 answers
100 views

Python Bokeh getting error in adding colorbar to plot

I have following code (part of it). I am trying to add a color bar for the palette used in the plot. I am successful in getting the plot but not he colorbar. from bokeh.palettes import Turbo256 from ...
Rajesh Patel's user avatar
2 votes
2 answers
40 views

How to determine if an axes already as a colorbar?

I would like to determine if an axes already has a colorbar. I have code which plots many objects on the same axes, but I only want to create and define the colorbar once to make things more efficient....
David K's user avatar
  • 1,346
0 votes
3 answers
42 views

How to change numbers on axis of colour bar

I have produced a contour plot and have a colour bar but it's labels are such random numbers which I assume just comes from the data and I've been trying to find a way to relabel it so the numbers go ...
Ella S's user avatar
  • 15
0 votes
1 answer
88 views

How to retrieve a colorbar from an already existing matplotlib scatter figure

I am trying to create a figure for a paper compounding previous matplotlib figures that I have saved in pickle format. For doing so I have used the get_offsets() command, which allows me to retrieve ...
Paulalo's user avatar
0 votes
1 answer
80 views

ggplot map - adding numeric label on colorbar

How can I add starting and ending numeric label on color bar ggplot map figure. For now my code looks like this: my_breaks <- c(1,60000,1200000,24000000,320000000) ggplot(data = opcine_spojeno) + ...
kosk's user avatar
  • 252
0 votes
1 answer
40 views

Changing the color of a colorbar in certain sections based on a third variable

I have the following code. I'm trying to have the values of De_below_line show up as a different color on the colorbar. The colorbar itself should have the range from De.min() to De.max(). While I can ...
Scott's user avatar
  • 63
1 vote
1 answer
100 views

Using x for the value of a colormap/colorbar instead of z

I have a function x = F(z,y). I want to map the x value to the color. How do I do this? Partial code: z = r * np.cos(theta) y = r * np.sin(theta) x = V(r, V_avg,R) # Create a 3D plot fig = plt.figure(...
remusconnor's user avatar
0 votes
1 answer
99 views

How to align text with the edge of the rightmost element in a matplotlib figure?

The following code aligns some text to the right edge of the color bar: import matplotlib.pyplot as plt import numpy as np data = np.random.rand(10, 10) img = plt.imshow(data, cmap='viridis') ...
chrisprt's user avatar
0 votes
1 answer
47 views

How to change range of an colorbar in matplotlib?

I'm trying to create a plot of ocean surface nitrate (downloaded from NOAA). I'm having trouble adjusting the colorbar while keeping the other elements of the plot. I would like the colorbar to range ...
Hanna's user avatar
  • 1
0 votes
0 answers
36 views

How to make colorbar in geopandas?

I want to draw topography of South Korea , and I tried to. everything's ok, but it was matter that I don't know how to show colorbar. It is my code and my figureenter image description here Please ...
FANA's user avatar
  • 1
0 votes
0 answers
41 views

how to draw a colorbar with a white boundary [duplicate]

usually, when uses fig.colorbar(),it output like this but when I need to draw a colorbar inside a figure, I want a colorbar with a white boundary. how can I do that? I cant find any example like this. ...
Auroralin's user avatar
0 votes
0 answers
39 views

How can I plot only the range of the colorbar that is used in the data? [duplicate]

I plot a heatmap using seaborn. First I get the min and max of the data to plot: vmin, vmax = np.nanmin(data), np.nanmax(data) Then I find the absolute maximum of both values: v_ext = np.max( [ np....
hefl99's user avatar
  • 1
0 votes
0 answers
44 views

plt.colorbar() generates wrong ticks

I'm currently working on plotting data using plt.imshow() and plt.colorbar() in Python. class MidpointNormalize(mcolors.Normalize): def __init__(self, vmin=None, vmax=None, midpoint=None, clip=...
hefl99's user avatar
  • 1
0 votes
1 answer
75 views

Maintain original image resolution in plot with colorbar

I have a greyscale image of some dimensions (height x width). I would like to produce a plot of this image along with a colorbar aligned with the image so that the resolution of the image in this plot ...
sleepingrabbit's user avatar
0 votes
0 answers
16 views

How to change the font of a colorbar ticks parameter on the label?

I want to use a consistent font throughout my figure (Times New Roman). But I can't modify the font next to the tick label, can anyone tell me? import pandas as pd import matplotlib.pyplot as plt ...
Liheng Wang's user avatar
0 votes
1 answer
27 views

Scale colour over multiple graphs

I have this function that plots data along two axes, and colours them according to their distance to the diagonal: def scatter_diagdistance(x, y) : z = abs(y-x) fig, ax = plt.subplots(dpi=200) ...
Whitehot's user avatar
  • 477
0 votes
1 answer
113 views

How to update quadmesh when figure changes size

i have the following problem in matplotlib (using python 3.x). I want to use a qudmesh with a frame that changes constantly. if the frame has the same initial size, that is ok. the problem is my frame ...
Josh.h's user avatar
  • 61
0 votes
0 answers
25 views

matplotlib value colorbar for scatter colors LogNorm

I do understand that the '''matplotlib.colors.lognorm''' will represent my value between [0:1]. How could I have the value next to the graduation? In other case : Is there any possibility to display ...
Johnvador's user avatar
0 votes
2 answers
224 views

python plotly colorbar for opacity

I have a figure with multiple traces in it with different opacity and same color(green). The lines in my plot are overlapping, therefore I need some opacity of the lines, which than indicates another ...
J.S.'s user avatar
  • 13
2 votes
1 answer
367 views

Using colorbar and nested tiledlayout

I'm trying to generate some nested tiledlayouts and have a colorbar associated with all of them. There is a way to put a colorbar on the outside of a single tiledlayout (here): However, this fails ...
magnesium's user avatar
  • 445
1 vote
1 answer
193 views

How to add positive and negative logarithmic scaled colorbars

I'm trying to create a 2D heatmap in Python using matplotlib, but I'm running into difficulty when it comes to handling both positive and negative values. My dataset contains values that range from ...
Tanus Szabo's user avatar
0 votes
0 answers
61 views

follow up on 'How can I add triangles to a ggplot2 colorbar in R to indicate out of bound values?'

In this question (https://stackoverflow.com/questions/68440366) a solution was proposed for vertical color bar. I wonder if a more general solution, or a package, has been developed since then that ...
Riccardo's user avatar

1
2 3 4 5
26