I want to set a variable marker size in a scatter plot. This is my code:
import numpy as np import matplotlib.pyplot as plt  from os import getcwd from os.path import join, realpath, dirname  mypath = realpath(join(getcwd(), dirname(__file__))) myfile = 'b34.dat'  data = np.loadtxt(join(mypath,myfile),      usecols=(1,2,3),      unpack=True)  fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(data[0], data[1], 'bo', markersize=data[2], label='the data') plt.show()   The file I'm importing has three columns. Columns 1 and 2 are stored in data[0] and data[1]) are the (x,y) values and I want each point to have a size relative to column 3 (ie: data[2])
I'm using the Canopy IDE by the way.
Set the figure size and adjust the padding between and around the subplots. Create random data points, x. Plot x data points using plot() method, with linewidth =0.5 and color="black".
Marker size is scaled by s and marker color is mapped to c . size in points^2. Default is rcParams['lines. markersize'] ** 2 .
help(plt.plot) shows
  markersize or ms: float            so it appears plt.plot does not allow the markersize to be an array. 
You could use plt.scatter however:
ax1.scatter(data[0], data[1], marker='o', c='b', s=data[2], label='the data')   PS. You can also verify that plt.plot's markersize must be a float by searching for "markersize" in the official documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With