Search code examples
rpycharm

How to show plot made in R in pycharm?


I'm learning R, for one of my projects. I use it in combination with the JetBrains Pycharm IDE.

It seems that it has out of the box support for R. However when I plot something nothing shows up in the "SciView" or "R Graphics" window.

The R code does generate a pdf file with the correct plot.

I use this code:

# Title     : TODO
# Objective : TODO
# Created by: boatfolder
# Created on: 2019-03-04

print("Hello world")

# Define the cars vector with 5 values
cars <- c(1, 3, 6, 4, 9)

# Graph cars using blue points overlayed by a line
plot(cars, type="o", col="blue")

# Create a title with a red, bold/italic font
title(main="Autos", col.main="red", font.main=4)

And this is how the result looks like:

result

Why is it not showing up in the "SciView" or "R Graphics" window?


Solution

  • It's disable now: https://github.com/holgerbrandl/r4intellij/issues/134

    I use jpeg(...) to set ouput file name like:

    jpeg("plot.jpg")
    plot(c(1, 2, 3), c(1, 2, 3))
    

    Hope it will be useful for someone