title: Importing matplotlib.pyplot in Rstudio using reticulate
body: <p>I am unable to <code>import matplotlib.pyplot as plt</code> in Rstudio.</p>
  
  <p>I tried the solutions already available on SO.</p>
  
  <p>Here are my attempts:</p>
  
  <p>I installed reticulate package the devtools install way.
  <code>devtools::install_github(rstudio/reticulate)</code></p>
  
  <p><code>library(reticulate)</code></p>
  
  <p><code>repl_python()</code></p>
  
  <p><code>import matplotlib.pyplot as plt</code></p>
  
  <p><code>import numpy as np</code></p>
  
  <p><code>x = np.linspace(0,10, 100)
   plt.plot(x, x, label = "linear")
   plt.legend()
   plt.show()</code></p>
  
  <p>I received the following error -
  <code>RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa ImportError: numpy.core.multiarray failed to import</code></p>
  
  <p>I tried in RMarkdown as well.</p>
  
  <pre><code>```{r setup, include=FALSE}
  knitr::opts_chunk$set(echo = TRUE)
  library(knitr)
  library(reticulate)
  use_condaenv(condaenv = "python36", conda = "auto", required = FALSE)
  ```
  
  ```{python}
  repl_python()
  import numpy as np
  import matplotlib.pyplot as plt
  
  n = 256
  X = np.linspace(-np.pi,np.pi,n,endpoint=True)
  Y = np.sin(2*X)
  
  plt.plot (X, Y+1, color='blue', alpha=1.00)
  plt.plot (X, Y-1, color='blue', alpha=1.00)
  plt.show()
  ```
  </code></pre>
  
  <p>Received the following error -</p>
  
  <p><code>RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
      Traceback (most recent call last):
      File "C:\Users\Vidhya\AppData\Local\Temp\Rtmp6vCzV6\chunk-code-13e83c491e61.txt", line 2, in &lt;module&gt;
      import matplotlib.pyplot as plt
    File "C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 29, in &lt;module&gt;
      import matplotlib.colorbar
    File "C:\Anaconda3\lib\site-packages\matplotlib\colorbar.py", line 32, in &lt;module&gt;
      import matplotlib.artist as martist
    File "C:\Anaconda3\lib\site-packages\matplotlib\artist.py", line 15, in &lt;module&gt;
      from .transforms import (Bbox, IdentityTransform, TransformedBbox,
    File "C:\Anaconda3\lib\site-packages\matplotlib\transforms.py", line 39, in &lt;module&gt;
      from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
  ImportError: numpy.core.multiarray failed to import
  </code></p>