Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # doubling the width of markers
- x = [0,2,4,6,8,10]
- y = [0]*len(x)
- s = [20*4**n for n in range(len(x))]
- plt.scatter(x,y,s=s)
- plt.show()
- # doubling the area of markers
- x = [0,2,4,6,8,10]
- y = [0]*len(x)
- s = [20*2**n for n in range(len(x))]
- plt.scatter(x,y,s=s)
- plt.show()
- plt.scatter(2, 1, s=4000, c='r')
- plt.scatter(2, 1, s=1000 ,c='b')
- plt.scatter(2, 1, s=10, c='g')
- import numpy as np
- import matplotlib.pyplot as plt
- x1 = np.random.randn(20)
- x2 = np.random.randn(20)
- plt.figure(1)
- # you can specify the marker size two ways directly:
- plt.plot(x1, 'bo', markersize=20) # blue circle with size 10
- plt.plot(x2, 'ro', ms=10,) # ms is just an alias for markersize
- plt.show()
- import matplotlib.pyplot as plt
- input_list = [{'x':100,'y':200,'radius':50, 'color':(0.1,0.2,0.3)}]
- output_list = []
- for point in input_list:
- output_list.append(plt.Circle((point['x'], point['y']), point['radius'], color=point['color'], fill=False))
- ax = plt.gca(aspect='equal')
- ax.cla()
- ax.set_xlim((0, 1000))
- ax.set_ylim((0, 1000))
- for circle in output_list:
- ax.add_artist(circle)
- import matplotlib.pyplot as plt
- fig,ax = plt.subplots()
- ax.plot([0],[0], marker="o", markersize=10)
- ax.plot([0.07,0.93],[0,0], linewidth=10)
- ax.scatter([1],[0], s=100)
- ax.plot([0],[1], marker="o", markersize=22)
- ax.plot([0.14,0.86],[1,1], linewidth=22)
- ax.scatter([1],[1], s=22**2)
- plt.show()
- 1 point == fig.dpi/72. pixels
- import matplotlib.pyplot as plt
- for dpi in [72,100,144]:
- fig,ax = plt.subplots(figsize=(1.5,2), dpi=dpi)
- ax.set_title("fig.dpi={}".format(dpi))
- ax.set_ylim(-3,3)
- ax.set_xlim(-2,2)
- ax.scatter([0],[1], s=10**2,
- marker="s", linewidth=0, label="100 points^2")
- ax.scatter([1],[1], s=(10*72./fig.dpi)**2,
- marker="s", linewidth=0, label="100 pixels^2")
- ax.legend(loc=8,framealpha=1, fontsize=8)
- fig.savefig("fig{}.png".format(dpi), bbox_inches="tight")
- plt.show()
Add Comment
Please, Sign In to add comment