colorbar

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

陌路散爱 提交于 2021-02-10 03:45:51
问题 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

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

空扰寡人 提交于 2021-02-10 03:44:22
问题 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

Python colorbar ticks are labeled with an offset of +1 and not with specifed values

梦想与她 提交于 2021-02-08 15:27:11
问题 I'm trying to do a contourf plot of the divergence of a vector field with python and then add a colorbar to this plot. My levels are intended to be symmetric around zero from -0.01 to 0.01. This is a part of my code: div_levs = [-0.01, -0.005, -0.0025, 0.0025, 0.005, 0.01] col = ['Blue', 'SteelBlue', 'White', 'Orange', 'Red'] c = plt.contourf(iwrf['x'], iwrf['y'], np.squeeze(iwrf['DIV'][ind_lev,:,:]), levels=div_levs, colors=col, extend='both') c.cmap.set_over('Magenta') c.cmap.set_under(

Adding one colorbar to multiple plots in one graph

♀尐吖头ヾ 提交于 2021-02-05 11:54:20
问题 I'm trying to attach the colorbar to my MatplotLib plot which plots several plots in one graph ( I'm not looking for a single colorbar to multiple subplots ). In my script I load files and plot runs of variables, however I'd like to colorize them regarding to the third variable. I found a way to do it, however it plots colorbar to each plot, and it looks like: 1 I'd like it to look like: 2, except every path should be colorized. Here is my block of code generating the plots: import os import

Python matplotlib custom colorbar for plotted lines with manually assigned colors

你说的曾经没有我的故事 提交于 2021-01-29 21:43:11
问题 I'm trying to define a colorbar for the following type of plot. import matplotlib.pyplot as plt import numpy as np for i in np.arange(0,10,0.1): plt.plot(range(10),np.ones(10)*i,c=[i/10.,0.5,0.25]) plt.show() This is just a simplified version of my actual data, but basically, I'd like a series of lines plotted and colored by another variable with a colorbar key. This is easy to do in scatter, but I can't get scatter to plot connected lines. Points are too clunky. I know this sounds like basic

Colorbar is overlapping with Contour Plot in Plotly

﹥>﹥吖頭↗ 提交于 2021-01-29 06:50:55
问题 I am getting margin on the left and right of the first subplot (please look at the image I have included at the end of the post) of the contour which I do no understand. Moreover, I can not position correctly the colorbar in the second plot. How can I fix the code? def bern(theta, z, N): """Bernoulli likelihood with N trials and z successes.""" return np.clip(theta**z * (1-theta)**(N-z), 0, 1) def bern2(theta1, theta2, z1, z2, N1, N2): """Bernoulli likelihood with N trials and z successes."""

2x2 Contourf plots sharing the same colorbar

杀马特。学长 韩版系。学妹 提交于 2021-01-28 02:26:46
问题 I would like to add a single color bar on the right side of the following 2x2 plot. import matplotlib.pyplot as plt import numpy as np x = np.linspace(-np.pi*2, np.pi*2, num=50) y = np.linspace(-np.pi*2, np.pi*2, num=50) def fun(x, y, pw1, pw2): X,Y = np.meshgrid(x, y) return (X, Y, np.cos(X*Y)**pw1 + np.sin(X+Y)**pw2) X, Y, f01 = fun(x,y,0,1) X, Y, f10 = fun(x,y,1,0) X, Y, f11 = fun(x,y,1,1) X, Y, f12 = fun(x,y,1,2) fig1, axs = plt.subplots(nrows=2,ncols=2, figsize=(8,8),sharex='col', sharey

2x2 Contourf plots sharing the same colorbar

对着背影说爱祢 提交于 2021-01-27 22:50:41
问题 I would like to add a single color bar on the right side of the following 2x2 plot. import matplotlib.pyplot as plt import numpy as np x = np.linspace(-np.pi*2, np.pi*2, num=50) y = np.linspace(-np.pi*2, np.pi*2, num=50) def fun(x, y, pw1, pw2): X,Y = np.meshgrid(x, y) return (X, Y, np.cos(X*Y)**pw1 + np.sin(X+Y)**pw2) X, Y, f01 = fun(x,y,0,1) X, Y, f10 = fun(x,y,1,0) X, Y, f11 = fun(x,y,1,1) X, Y, f12 = fun(x,y,1,2) fig1, axs = plt.subplots(nrows=2,ncols=2, figsize=(8,8),sharex='col', sharey

2x2 Contourf plots sharing the same colorbar

假装没事ソ 提交于 2021-01-27 20:56:09
问题 I would like to add a single color bar on the right side of the following 2x2 plot. import matplotlib.pyplot as plt import numpy as np x = np.linspace(-np.pi*2, np.pi*2, num=50) y = np.linspace(-np.pi*2, np.pi*2, num=50) def fun(x, y, pw1, pw2): X,Y = np.meshgrid(x, y) return (X, Y, np.cos(X*Y)**pw1 + np.sin(X+Y)**pw2) X, Y, f01 = fun(x,y,0,1) X, Y, f10 = fun(x,y,1,0) X, Y, f11 = fun(x,y,1,1) X, Y, f12 = fun(x,y,1,2) fig1, axs = plt.subplots(nrows=2,ncols=2, figsize=(8,8),sharex='col', sharey

How can I add a label to colorbar using ImageGrid?

我是研究僧i 提交于 2021-01-27 08:56:27
问题 In a previous question, colobar label matplotlib in ImageGrid, had a solution for adding a label to the colorbar, but this seems to be broken with the current version. Platforms I have tried: Mac w/ Canopy: python: 2.7 matplotlib: 1.4.3-6 Linux: python: 2.7 matplotlib: 1.3.1 Below is the code from the previous question, with some extra code for running in an iPython notebook: import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import AxesGrid def get_demo_image(): import numpy as np