python 2.7 - 2D color plot when one of the dimensions has a single value -
i trying make 2-d color plot script formerly dealing rectangle of data. however, need use work single point on x axis having data.
what i've got is:
self.fig = plt.figure('title', (10.,10.)) ax=plt.subplot(111) im=ax.imshow(color_array,interpolation='none',extent=[100,100,50,150],aspect=0.15) # setting labels, climate, color bar, saving image, etc..
i'm sure what's causing issue extent = [100,100
, i'm not sure how write code differently in order plot show other narrow vertical rectangle nothing inside.
the color array typically 2-d array of numbers, in limited case, 1-d array. happens is, there 3 2-d arrays, same dimensions, , 2 of them make x , y axes, , third (the color array) determines coloring of field. right (simplified) this:
y-axis: [[90,100,110,120]]
x-axis: [[100,100,100,100]]
color: [[10,11,13,14]]
the answer turned out simple. that's required simple adjustment extent. basically, make sure 2 values on same axes have distance of larger 0 between them.
im=ax.imshow(color_array,interpolation='none',extent[100-1,100+1,50,150],aspect=0.15)
i used value of 1 separate above, really, number work (you can scale changing dimensions of plots if consistent).
i used if
statement make sure occurs in situations first index of axis array equal last index.
Comments
Post a Comment