python - Add colorbar to scatter plot or change the plot type -


i plotting data includes spatial (x, y) components z component, value of measurement @ point in space. looking @ gallery, , i'm not getting it. think want pcolormesh, don't understand need put in arguments. had success getting scatter plot want, it's less pretty want. if figure out way make points in scatter plot bigger, lot happier plot. furthermore, stuck on trying add legend - need colorbar portion, since end user doesn't care x , y dimensions. looking @ colorbar example, seems need add axis, don't understand how i'm telling axis need z axis.

x_vals = list(first_array[data_loc_dictionary['x_coord_index']][:]) y_vals = list(first_array[data_loc_dictionary['y_coord_index']][:]) y_vals = [-i in y_vals] z_vals = list(first_array[data_loc_dictionary['value_index']][:])  plt.scatter(x_vals, y_vals, s = len(x_vals)^2, c = z_vals, cmap = 'rainbow') plt.show() 

here example of trying duplicate: enter image description here , here code above produces: enter image description here

  • i second little more first, i.e., if there way adjust markers large enough approximate look, ideal
  • i struggling creating legend. colorbar seems way go, not comprehending how specify needs based on z values.

good catch ^2 - enter image description here

what basic example:

# generate random data in [63]: x = np.random.rand(20) in [64]: y = np.random.rand(20) in [65]: z = np.random.rand(20)  # plot square markers: marker='s' in [66]: plt.scatter(x, y, s=len(x)**2, c=z, cmap='rainbow', marker='s') out[66]: <matplotlib.collections.pathcollection @ 0x39e6c90>  # colorbar in [67]: c = plt.colorbar(orientation='horizontal') in [68]: c.set_label('this colorbar') in [69]: plt.show() 

enter image description here

the size of points given by

s : scalar or array_like, shape (n, ), optional, default: 20      size in points^2. 

i see no reason why s=len(x)**2 choice default. play around according preference.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -