Guest User

Untitled

a guest
Nov 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. # doubling the width of markers
  2. x = [0,2,4,6,8,10]
  3. y = [0]*len(x)
  4. s = [20*4**n for n in range(len(x))]
  5. plt.scatter(x,y,s=s)
  6. plt.show()
  7.  
  8. # doubling the area of markers
  9. x = [0,2,4,6,8,10]
  10. y = [0]*len(x)
  11. s = [20*2**n for n in range(len(x))]
  12. plt.scatter(x,y,s=s)
  13. plt.show()
  14.  
  15. plt.scatter(2, 1, s=4000, c='r')
  16. plt.scatter(2, 1, s=1000 ,c='b')
  17. plt.scatter(2, 1, s=10, c='g')
  18.  
  19. import numpy as np
  20. import matplotlib.pyplot as plt
  21.  
  22. x1 = np.random.randn(20)
  23. x2 = np.random.randn(20)
  24. plt.figure(1)
  25. # you can specify the marker size two ways directly:
  26. plt.plot(x1, 'bo', markersize=20) # blue circle with size 10
  27. plt.plot(x2, 'ro', ms=10,) # ms is just an alias for markersize
  28. plt.show()
  29.  
  30. import matplotlib.pyplot as plt
  31. input_list = [{'x':100,'y':200,'radius':50, 'color':(0.1,0.2,0.3)}]
  32. output_list = []
  33. for point in input_list:
  34. output_list.append(plt.Circle((point['x'], point['y']), point['radius'], color=point['color'], fill=False))
  35. ax = plt.gca(aspect='equal')
  36. ax.cla()
  37. ax.set_xlim((0, 1000))
  38. ax.set_ylim((0, 1000))
  39. for circle in output_list:
  40. ax.add_artist(circle)
  41.  
  42. import matplotlib.pyplot as plt
  43.  
  44. fig,ax = plt.subplots()
  45.  
  46. ax.plot([0],[0], marker="o", markersize=10)
  47. ax.plot([0.07,0.93],[0,0], linewidth=10)
  48. ax.scatter([1],[0], s=100)
  49.  
  50. ax.plot([0],[1], marker="o", markersize=22)
  51. ax.plot([0.14,0.86],[1,1], linewidth=22)
  52. ax.scatter([1],[1], s=22**2)
  53.  
  54. plt.show()
  55.  
  56. 1 point == fig.dpi/72. pixels
  57.  
  58. import matplotlib.pyplot as plt
  59.  
  60. for dpi in [72,100,144]:
  61.  
  62. fig,ax = plt.subplots(figsize=(1.5,2), dpi=dpi)
  63. ax.set_title("fig.dpi={}".format(dpi))
  64.  
  65. ax.set_ylim(-3,3)
  66. ax.set_xlim(-2,2)
  67.  
  68. ax.scatter([0],[1], s=10**2,
  69. marker="s", linewidth=0, label="100 points^2")
  70. ax.scatter([1],[1], s=(10*72./fig.dpi)**2,
  71. marker="s", linewidth=0, label="100 pixels^2")
  72.  
  73. ax.legend(loc=8,framealpha=1, fontsize=8)
  74.  
  75. fig.savefig("fig{}.png".format(dpi), bbox_inches="tight")
  76.  
  77. plt.show()
Add Comment
Please, Sign In to add comment