Skip to content
Advertisement

Draw scatterplots on different plots

I have a custom function that creates a scatterplot:

JavaScript

The idea is to get a scatterplot that has x errors and y errors on it, as well as a color scheme based on a different column.

I’ve noticed that if I were to do use d1 (of 5 points total) like this:

JavaScript

And then another d2 (of 5 points total) like this:

JavaScript

I’d get 1 plot with 10 points. I want 2 plots with 5 points (each belonging to d1 and d2). How do I modify the function to accomodate this?

Advertisement

Answer

The documentation highlights why this behavior happens.

By calling fig=plt.figure(1) you create a new figure if there is no other figure with the same identifier. In your case, this means the 1. In your case, the figure with the identifier with the 1 is always restored and no new figure is created.

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure

From the documentation:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement