Here is the explanation of the preceding code:
- im = ax.scatter(x, y, c=iris.petal_length, s=100*iris.petal_width, cmap='viridis', alpha=0.7) plots the scatter graph on the main axes, as follows:
- x and y are the sepal_length and sepal_width variables to be plotted.
- c=iris.petal_length specifies that the color of points should be according to their petal_length value.
- s=100*iris.petal_width specifies that the size of the points on the scatter graph should be according to their petal_width value, multiplied by 100.
- cmap='viridis' specifies the colormap to be used.
- alpha=0.7 specifies the transparency level of the points on the plot.
- plt.colorbar(im) plots the colorbar on the right-hand side of the main axes.
- inset_ax1 = inset_axes(ax, ...