contourf

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,

3D plot with Matplotlib

て烟熏妆下的殇ゞ 提交于 2021-02-05 20:10:48
问题 I'm simply trying to plot a surface and its contour in 3D, exactly as in this example. This is the code I'm using to do it: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import numpy def plot_3d_contour(x_dim, y_dim, x_steps, y_steps, scalar_field, file_path): fig = plt.figure() x, y = numpy.mgrid[-x_dim/2:x_dim/2:x_steps*1j, -y_dim/2:y_dim/2:y_steps*1j] v_min = numpy.min(scalar_field) v_max = nupmy.max(scalar_field) ax = fig.gca(projection=

3D plot with Matplotlib

偶尔善良 提交于 2021-02-05 20:01:30
问题 I'm simply trying to plot a surface and its contour in 3D, exactly as in this example. This is the code I'm using to do it: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import numpy def plot_3d_contour(x_dim, y_dim, x_steps, y_steps, scalar_field, file_path): fig = plt.figure() x, y = numpy.mgrid[-x_dim/2:x_dim/2:x_steps*1j, -y_dim/2:y_dim/2:y_steps*1j] v_min = numpy.min(scalar_field) v_max = nupmy.max(scalar_field) ax = fig.gca(projection=

3D plot with Matplotlib

霸气de小男生 提交于 2021-02-05 19:59:11
问题 I'm simply trying to plot a surface and its contour in 3D, exactly as in this example. This is the code I'm using to do it: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d from matplotlib import cm import numpy def plot_3d_contour(x_dim, y_dim, x_steps, y_steps, scalar_field, file_path): fig = plt.figure() x, y = numpy.mgrid[-x_dim/2:x_dim/2:x_steps*1j, -y_dim/2:y_dim/2:y_steps*1j] v_min = numpy.min(scalar_field) v_max = nupmy.max(scalar_field) ax = fig.gca(projection=

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

python pyplot: colorbar on contourf and scatter in same plot

坚强是说给别人听的谎言 提交于 2020-08-22 06:57:14
问题 I have two different datasets. One is a numpy NxM matrix and another is a Lx3 pandas dataframe. I am overlaying scatter plot (Lx3 dataframe) on top of a contour plot (NxM) and the colorbar is scaling based on the scatter plot data. How can I force the colorbar to scale based on both data sets (How can I synchronize the colorbar on both plot layers) ? import numpy as np import matplotlib.pyplot as plt #generate random matrix with min value of 1 and max value 5 xx = np.random.choice(a = [1,2,3