2016-06-28 7 views
1

Ich versuche, ein Konturdiagramm einzurichten, aber die Figur endet wie folgt aussehen:Einstellen Maschen xy Skala Konturplot matplotlib

fig1.

Ich denke es liegt daran, dass die y-Achse von etwa 10 bis 80 Einheiten und die x nur 4 bis 9 Einheiten und das Netz ist quadratisch, so dass jede Einheit ist das gleiche auf der X- und Y-Achse skaliert. Wie kann ich die Skalierung der X-Achse ändern, um daraus ein brauchbares Bild zu machen?

import numpy as np 
import matplotlib.pyplot as plt 
import time as time 
from scipy.interpolate import griddata 

x = np.array([3.98, 3.98, 3.99, 3.98, 6.02, 6.05, 6.03, 6.04, 10.01, 10.07, 10.09, 10.1]) 
y = np.array([79.5, 40, 20.07, 10.04, 79.67, 40.08, 20.23, 10.01, 79.42, 39.63, 20.14, 10.11]) 
z = np.array([38.82697111, 34.61715402, 22.46052757, 13.51888155, 48.52466738, 42.1140194, 28.37788811, 16.48901657, 55.40461783, 46.88792485, 33.66091083, 20.9200696]) 

extent = (min(x), max(x), min(y), max(y)) 
xs,ys = np.mgrid[extent[0]:extent[1]:30j, extent[2]:extent[3]:30j] 
resampled = griddata((x, y), z, (xs, ys)) 
plt.figure(figsize=(8,8)) 
plt.imshow(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic') 
plt.contour(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic',origin='upper') 
plt.hold(True) 
plt.scatter(x,y,c=z) 
plt.gca().invert_yaxis() 
plt.colorbar() 
plt.show() 
+0

so einfach zu bedienen ist, danken Sie! –

Antwort

1

Setzen Sie einfach den aspect Schlüsselwort entweder manuell:

plt.imshow(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic', aspect=0.1) 

oder durch die auto Option:

plt.imshow(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic', aspect='auto') 

Eine weitere Option pcolormesh()

Verwandte Themen