Rstudio on Windows 10

Hello,

Hope you are fine. I am actually using R 3.6.1 on Windows 10. I have the last version of Rstudio installed. I added anaconda and reticulate so I could run both python and R.
I actually have an issue with matplotlib, I don't have this issue on ubuntu with Rstudio server and jupyter notebook.
I can't plot matplotlib objects in python. Here is the code.

import numpy as np
import matplotlib.pyplot as plt

vecteur_aleatoir = np.random.rand(50)
plot = plt.scatter(range(50),vecteur_aleatoir)
plot

R tells me this : <matplotlib.collections.PathCollection object at 0x00000274AF91DF48>

when I call plot.show(), it tells :

AttributeError: 'PathCollection' object has no attribute 'show'

*Detailed traceback: *

  • File "", line 1, in *

Using Jupyter notebook on the same computer, I got no issues calling just "plot".

Maybe I should definitely turn my head on linux for working on R and Python.

Thanks to anybody willing to help.

I think you are making a typo, you have imported matplotlib as plt, so the last command would be plt.show(), This code works for me with a similar setup (Windows 10, R 3.6.1, RStudio 1.2.5018, reticulate 1.13)

import numpy as np
import matplotlib.pyplot as plt

vecteur_aleatoir = np.random.rand(50)
plot = plt.scatter(range(50),vecteur_aleatoir)
plt.show()

Good, thank you very much. plt.show() works for me. And what about calling just "plot"? It works on Jupyter and Rstudio server installed on AWS instance.

So the good way is to always call plt.show() each time rather than just calling "plot", the variable?

Well, I have tried on a python script on RStudio Server and calling just plot doesn't work, I also have to call plt.show().

Thank you @andresrcs

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.