Matplotlib 3.0 Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

The following is the explanation for the code:

  • pd.read_csv() reads the data and replaces the descriptive names with numeric codes, as explained earlier.
  • s = 50 * iris.petal_length * iris.petal_width specifies the size of the bubble. It essentially represents the area. The constant 50 used in the formula for s is a random number that multiplies the area of every point by this constant. The smaller this constant is, the smaller the relative sizes of all the points will be. Try changing this constant from 25, and then to 50 and then to 100 and see how the sizes of bubbles change. Without this multiplier, the size of some of the points is too small to observe them in the plot.
  • c = iris.species specifies different classes (clusters) in the data. The pyplot method uses this to represent each of these classes in different colors. 
  • alpha=0.3 specifies the appearance of the bubble and decides how transparent the bubble should be. This can range from 0 to 1; if the value is close to zero, the bubble is highly transparent and if it is close to 1, the bubble is highly opaque: