colorbar

How to control colorbar color ranges in Matlab plots?

让人想犯罪 __ 提交于 2021-02-19 04:27:06
问题 I have the following code: [X,Y,Z] = peaks(30); crange = 1.5; [maxval dummy] = max(Z(:)); [minval dummy] = min(Z(:)); % green, yellow, red cmap = [0 1 0; 1 1 0; 1 0 0]; figure colormap(cmap); surf(X,Y,Z); caxis([30 55]); cbh=colorbar; set(cbh,'Ytick',[30 32 38 55]); My goal is to set the limits of the color bar so that the colors are like this: green from 30 to 32 yellow from 32 to 38 red from 38 to 55 I believe I should somehow change the CData variable, so I used these lines of code without

How to control colorbar color ranges in Matlab plots?

∥☆過路亽.° 提交于 2021-02-19 04:27:05
问题 I have the following code: [X,Y,Z] = peaks(30); crange = 1.5; [maxval dummy] = max(Z(:)); [minval dummy] = min(Z(:)); % green, yellow, red cmap = [0 1 0; 1 1 0; 1 0 0]; figure colormap(cmap); surf(X,Y,Z); caxis([30 55]); cbh=colorbar; set(cbh,'Ytick',[30 32 38 55]); My goal is to set the limits of the color bar so that the colors are like this: green from 30 to 32 yellow from 32 to 38 red from 38 to 55 I believe I should somehow change the CData variable, so I used these lines of code without

Matplotlib normalize colorbar (Python)

孤街醉人 提交于 2021-02-18 12:45:39
问题 I'm trying to plot a contourf-plot using matplotlib (and numpy of course). And it works, it plots what it should plot, but unfortunatelly I cannot set the colorbar range. The problem is that I have a plenty of plots and need all of them to have the same colorbar (same min and max, same colors). I copy&past-ed almost every code snippet I found on the internet, but without success. My code so far: import numpy as np; import matplotlib as mpl; import matplotlib.pyplot as plt; [...] plotFreq,

How to visualize a list of strings on a colorbar in matplotlib

别来无恙 提交于 2021-02-17 05:20:11
问题 I have a dataset like x = 3,4,6,77,3 y = 8,5,2,5,5 labels = "null","exit","power","smile","null" Then I use from matplotlib import pyplot as plt plt.scatter(x,y) colorbar = plt.colorbar(labels) plt.show() to make a scatter plot, but cannot make colorbar showing labels as its colors. How to get this? 回答1: I'm not sure, if it's a good idea to do that for scatter plots in general (you have the same description for different data points, maybe just use some legend here?), but I guess a specific

Plotly contour subplots each having their own colorbar

隐身守侯 提交于 2021-02-16 15:21:31
问题 I am trying to generate contours using Plotly. There are 5 contours which I am plotting in a 5x1 grid using subplots. I am unable to see an option by which I can have a separate colorbar for each contour subplot. For line plots I can use shared_xaxes or shared_yaxes options, but unable to find documentation where I can have a separate colorbar for each subplot in this 5x1 grid. Here are some reference links I tried to go through: https://plot.ly/python/contour-plots/ https://plot.ly/python

colorbar changes the size of subplot in python

非 Y 不嫁゛ 提交于 2021-02-16 13:57:47
问题 I use the following code to generate side-by-size images and I need to add colorbar only to the second image in the row. I use the following code for it import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import matplotlib.gridspec as gridspec def plotting(x): gs1 = gridspec.GridSpec(1, 2) gs1.update(wspace=0.005, hspace=0.005) plt.subplot(gs1[0]) plt.imshow(x) plt.axis('off') plt.title('dog') ax1 = plt.subplot(gs1[1]) imc = plt.imshow(x, cmap='hot',

colorbar changes the size of subplot in python

做~自己de王妃 提交于 2021-02-16 13:57:10
问题 I use the following code to generate side-by-size images and I need to add colorbar only to the second image in the row. I use the following code for it import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import matplotlib.gridspec as gridspec def plotting(x): gs1 = gridspec.GridSpec(1, 2) gs1.update(wspace=0.005, hspace=0.005) plt.subplot(gs1[0]) plt.imshow(x) plt.axis('off') plt.title('dog') ax1 = plt.subplot(gs1[1]) imc = plt.imshow(x, cmap='hot',

Discrete Color Bar with Tick labels in between colors

限于喜欢 提交于 2021-02-15 04:55:11
问题 I am trying to plot some data with a discrete color bar. I was following the example given (https://gist.github.com/jakevdp/91077b0cae40f8f8244a) but the issue is this example does not work 1-1 with different spacing. For example, the spacing in the example in the link is for only increasing by 1 but my data is increasing by 0.5. You can see the output from the code I have.. Any help with this would be appreciated. I know I am missing something key here but cant figure it out. import

Discrete Color Bar with Tick labels in between colors

大兔子大兔子 提交于 2021-02-15 04:52:09
问题 I am trying to plot some data with a discrete color bar. I was following the example given (https://gist.github.com/jakevdp/91077b0cae40f8f8244a) but the issue is this example does not work 1-1 with different spacing. For example, the spacing in the example in the link is for only increasing by 1 but my data is increasing by 0.5. You can see the output from the code I have.. Any help with this would be appreciated. I know I am missing something key here but cant figure it out. import

Colorbar as a subplot in Gridspec (python): change size

元气小坏坏 提交于 2021-02-10 03:47:12
问题 I have this gridspec subplot in python: It is a 3x3 Gridspec matrix of seaborn heatmaps with a single colorbar occupying the whole third column. I would like to make the colorbar look shorter . The way I see it, there are two choices: a. Either I make the plot of the colorbar shorter b. I manage to reduce the available space for the last column in the gridspec. Unfortunately, I haven't found a proper way to do it. Could anyone help me? Here the code for clarity. Thank you very much in advance