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

How it works...

  • Plot 1 uses default settings for spines. So, it displays all four spines, with the left and bottom ones representing the y and x axes with appropriate ticks and ticklabels.
  • In plot 2, the top and right spines are made invisible using the set_visible(False) method. set_position('center') positions the x and y axes in between the corresponding data range. In this case, data on the y axis ranges from -1 to +1, so the center point is 0, and the x axis data ranges from 0 to 6, so the center point is 3. So, the intersection point is (3, 0).
  • Plot 3 places left and bottom spines in such a way that they intersect at (0, 0).
  • Plot 4 places left and bottom spines in such a way that they intersect at 0.25* range on x axis and 0.75* range on y axis. [0.25, 0.75] is 0.25 * x-range = 0.25 *(0 to 6) = 1.5, 0.75 * y-range = 0.75 * (-1 to 1) = 0.5. So, the intersection point is (1.5, 0.5). The axes option basically sets the bottom 25% (first quartile) on the x axis and the bottom 75% (third quartile) on y axis.
  • In plot 5, we use the data option to specify the position in the input data. So, it places the left and bottom spines to intersect at (1, -1).
  • In plot 6, we place the spines away from the graph using the outward argument by a specified number of units; here, it is 10: