contourf

python pyplot: colorbar on contourf and scatter in same plot

僤鯓⒐⒋嵵緔 提交于 2020-08-22 06:56:47
问题 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

2D Density Plot with X Y Z data

淺唱寂寞╮ 提交于 2020-05-17 07:26:25
问题 I am trying to plot 2d terrain map with x,y and z (elevation). I followed the steps from the following link but I am getting very weird plot. Python : 2d contour plot from 3 lists : x, y and rho? I spent almost half day searching but got nowhere. import numpy as np import matplotlib.pyplot as plt import scipy.interpolate # import data: import xlrd loc = "~/Desktop/Book4.xlsx" wb = xlrd.open_workbook(loc) sheet = wb.sheet_by_index(0) sample=500 # Generate array: x=np.array(sheet.col_values(0))

pyplot contourf with custom colormap repeats color instead of changing

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-24 12:52:10
问题 I want to plot some data with a logarithmic color code where a decade limit is indicated by a white/black interface. Grey levels are used to show some subdivisions of a decade. My problem is that there are two white neighboring regions in each decade even though the color map has the right number of entries (at least I think). Could someone help please? In the meantime I made some tests and I found that it's the second color of the repeating pattern that is not used (the gray(0.25)), but I

Python : How to export a contourf to a 2D array?

坚强是说给别人听的谎言 提交于 2020-01-06 08:15:32
问题 From a complex 3D shape, I have obtained by tricontourf the equivalent top view of my shape. I wish now to export this result on a 2D array. I have tried this : import numpy as np from shapely.geometry import Polygon import skimage.draw as skdraw import matplotlib.pyplot as plt x = [...] y = [...] z = [...] levels = [....] cs = plt.tricontourf(x, y, triangles, z, levels=levels) image = np.zeros((100,100)) for i in range(len(cs.collections)): p = cs.collections[i].get_paths()[0] v = p.vertices

matplotlib: assign color to a radius

半城伤御伤魂 提交于 2019-12-31 00:09:41
问题 I have a 3D plot of a disk. Now I would like to plot the surface in color depending on values which are stored in an array. E.g. the radius of the disk is 300mm. The array could like: arr = np.array([[ 114.28, 14], [ 128.57, 16], [ 142.85,19], [ 157.13,20], [ 171.41,21], [ 185.69,22], [ 199.97,24], [ 214.25,27], [ 228.53,29], [ 242.81,30], [ 257.09,31], [ 271.37,34], [ 288.65,35], [ 299.93,36], [ 300,38]]) It means for radius = 114.28 I have the value 14. I would like to plot a circle at

How to superimpose two contour maps onto each other in matlab?

放肆的年华 提交于 2019-12-29 09:19:09
问题 I have two contour maps in Matlab and each of the two maps has a single curve specifying a single Z-value. I want to super impose the two contour maps so that I can find the single solution where the two z-value curves intersect. How could I go about super imposing the two contour maps? % the two contour maps are coded the exact same way, but with different z-values x = 0.05:0.05:1; y = 0.0:0.05:1; [X, Y] = meshgrid(x, y); % Z-value data is copied from excel and pasted into an array Z = [data

How to increase the hatch density matplotlib?

与世无争的帅哥 提交于 2019-12-24 23:17:36
问题 I'm trying to increase the density of hatch marks I have for a map. This is how I'm currently doing it and I can't get anything to show up on my map when it should. I want to contour values less than 0.05 (sig p-valuea). And repeating the type of hashing I want doesn't help with the problem. levels = [spnewdata[:,:,1].min(), 0.05] cs1 = plt.contour(x, y, spnewdata[:,:,1],levels=levels, colors='none', hatch='X', alpha=0) Edit: Here's a little more complete form of the code I'm using to make

Scilab: same colormap in contourf

对着背影说爱祢 提交于 2019-12-23 05:35:13
问题 When the following program is run, It becomes the same figure. I want the same color-coding. x=-5:0.1:5; y=-5:0.1:5; [X,Y]=meshgrid(x,y); z1=X.^2+Y.^2-25; z2=X.^2+Y.^2-50; clf(); f=gcf(); f.color_map=jetcolormap(32); subplot(1,2,1); contourf([],[],z1,32); subplot(1,2,2); contourf([],[],z2,32); 回答1: I don't know how to do it with contourf , but if you can use surf instead, I have a suggestion. Please note, that surf generates a 3D plot, but you can rotate it to seem as a 2D plot. And as a

Create a contour plot from 3 vectors

↘锁芯ラ 提交于 2019-12-22 10:30:28
问题 I'm trying to create a contour plot from this data: pH D Tur 5.10 3 79.18918919 5.50 6 92.97297297 5.00 0 50.09009009 5.00 6 90.36036036 5.10 9 91.08108108 5.10 12 89.18918919 5.10 15 83.6036036 5.00 18 91.26126126 5.00 21 81.26126126 5.00 24 90.99099099 5.00 27 91.44144144 5.00 30 90.45045045 6.00 0 43.42342342 5.64 3 81.8018018 5.50 9 92.16216216 5.50 0 44.68468468 5.40 12 92.34234234 5.50 15 92.25225225 5.50 18 91.62162162 5.50 21 90.81081081 5.50 24 91.8018018 5.50 27 92.52252252 5.50 30

Creating a heatmap by sampling and bucketing from a 3D array

社会主义新天地 提交于 2019-12-22 09:46:55
问题 I have some experimental data that exists like so: x = array([1, 1.12, 1.109, 2.1, 3, 4.104, 3.1, ...]) y = array([-9, -0.1, -9.2, -8.7, -5, -4, -8.75, ...]) z = array([10, 4, 1, 4, 5, 0, 1, ...]) If it's convenient, we can assume that the data exists as a 3D array or even a pandas DataFrame : df = pd.DataFrame({'x': x, 'y': y, 'z': z}) The interpretation being, for every position x[i], y[i] , the value of some variable is z[i] . These are not evenly sampled , so there will be some parts that