python - how can I plot on the axes -


i want recreate image following: enter image description here

specially little x on xaxes have

list = [[100,-3],[200,none],[120,-2] ... ] 

and do

for x in list:      if x[1]!=none:           plot(x[0],x[1],'ok')      else:           ###  plot on axes ### 

but while plotting not know axes are. know values none, example ( 250,none), want plot on xaxes @ x = 250, have not idea min(ylim()) be.

i know can plot(250,-5,'x',zorder=999999) when know min axes is.. (i can not min, max , know min axes. real data list inside list inside dictionary etc.. )

so trick use custom transformation. regular data transformation x axis , axes transformation y axis. matplotlib calls blended transformation, need create yourself. you'll find more information in awesome guide.

and @thepredator pointed out, have set clip_on=false, otherwise markers clipped.

import numpy np import matplotlib.pyplot plt import matplotlib.transforms transforms  fig, ax = plt.subplots()  # x coords of transformation data, , # y coord axes trans = transforms.blended_transform_factory( ax.transdata, ax.transaxes)  # data points on axes x = np.random.rand(5)*100. + 200. y = [0]*5 ax.plot(x, y, 'kx', transform=trans, markersize=10, markeredgewidth=2,         clip_on=false)  # regular data x = np.random.rand(5)*100. + 200. y = np.random.rand(5)*100. + 200. ax.plot(x, y, 'ro')  plt.show() 

result:

enter image description here


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -