'Saving plots as variables in python like in R
When I work in R's ggplot() I can store my plots as p<-ggplot()... This makes it easier to add elements to the plot and look at them before they are saved. Is there a way to do this in python? For example, I would like to be able to add elements to the first figure, fig, after I plot the new z values.
What ggplot can do with R.
library(ggplot2)
p<-ggplot(mtcars,aes(x=factor(am),y=mpg))+geom_boxplot()
p+xlab("Transmission Type")+ylab("Miles Per Gallon (mpg)")
p
What I would like to do in Python.
import matplotlib.pyplot as plt
x = [1,2,3]
y = [2,4,1]
fig = plt.plot(x, y)
z = x*2
y = [2,4,1]
fig2 = plt.plot(z, y)
fig.show()
fig2.show()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
