Plots in ioslides and R markdown

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Plots in ioslides and R markdown

Patrick Connolly-4
I'm having difficulty getting plots into ioslides.  It seems to me
that the scale is completely out, but I can't figure out what to do
about it.  Whatever I try, I get the title slide, then a second with a
horizontal line and a vertical line in the bottom right corner.  It
looks like a badly scaled plot about 25 times the size of the plotting
area, so only a fragment is visible.

This is the code I've tried:

---
title: "Barking up the wrong tree"
author: "Patrick Connolly"
date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
output: ioslides_presentation
---

```{r global_options, echo=FALSE}
knitr::opts_chunk$set(tidy=TRUE,
                      warning=FALSE,
                      message=FALSE,
                      cache=FALSE,
                      dpi=600)
```

```{r use these functions, echo= FALSE}
  load(".RData") ## code for 6 plotting functions

``
## 6 different Trees

```{r 6 different Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}

###  par(mfrow = c(2, 3))
plot1()
plot2()
plot3()
plot4()
plot5()
plot6()
}
```

If I run the plot functions in the Console, it all works and displays
correctly in Rstudiio's plot panel, even the mfrow bit.  But I haven't
worked out how to include the code into Rmarkdown.  I thought it might
be less taxing to not try putting the 6 plots on the same slide, but
it makes no difference when I commented out the mfrow bit.

I'm not very familiar with the workings of Markdown or Rstudio, but it
does seem strange to me that I need to specifically load the global
environment otherwise it's not visible.  Is that to be expected?

Ideas welcome, particularly about scaling.

--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.  
   ___    Patrick Connolly  
 {~._.~}                   Great minds discuss ideas    
 _( Y )_           Average minds discuss events
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)                        ..... Eleanor Roosevelt
         
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Jeff Newmiller
This is not reproducible because you have not provided the plot code or sample data. Output of sessionInfo would probably be appropriate as well.

As to whether needing to load objects is typical... yes, rmarkdown runs from a fresh environment to emphasize reproducibility, but your load command is bypassing that for us.

On August 23, 2018 2:15:19 AM PDT, Patrick Connolly <[hidden email]> wrote:

>I'm having difficulty getting plots into ioslides.  It seems to me
>that the scale is completely out, but I can't figure out what to do
>about it.  Whatever I try, I get the title slide, then a second with a
>horizontal line and a vertical line in the bottom right corner.  It
>looks like a badly scaled plot about 25 times the size of the plotting
>area, so only a fragment is visible.
>
>This is the code I've tried:
>
>---
>title: "Barking up the wrong tree"
>author: "Patrick Connolly"
>date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
>output: ioslides_presentation
>---
>
>```{r global_options, echo=FALSE}
>knitr::opts_chunk$set(tidy=TRUE,
>                      warning=FALSE,
>                      message=FALSE,
>                      cache=FALSE,
>                      dpi=600)
>```
>
>```{r use these functions, echo= FALSE}
>  load(".RData") ## code for 6 plotting functions
>
>``
>## 6 different Trees
>
>```{r 6 different Trees, echo = FALSE, messages=FALSE, fig.width = 7,
>fig.height = 5}
>
>###  par(mfrow = c(2, 3))
>plot1()
>plot2()
>plot3()
>plot4()
>plot5()
>plot6()
>}
>```
>
>If I run the plot functions in the Console, it all works and displays
>correctly in Rstudiio's plot panel, even the mfrow bit.  But I haven't
>worked out how to include the code into Rmarkdown.  I thought it might
>be less taxing to not try putting the 6 plots on the same slide, but
>it makes no difference when I commented out the mfrow bit.
>
>I'm not very familiar with the workings of Markdown or Rstudio, but it
>does seem strange to me that I need to specifically load the global
>environment otherwise it's not visible.  Is that to be expected?
>
>Ideas welcome, particularly about scaling.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Patrick Connolly-4
On Thu, 23-Aug-2018 at 07:23AM -0700, Jeff Newmiller wrote:

|> This is not reproducible because you have not provided the plot
|> code or sample data. Output of sessionInfo would probably be
|> appropriate as well.

I took it as read that the plotting functions themselves aren't an
issue since they operate as intended outside of the Rmarkdown
space. Any function that uses the function plot() successfully will
do.  I was trying to ascertain how I should be setting up the scaling.

|> As to whether needing to load objects is typical... yes, rmarkdown
|> runs from a fresh environment to emphasize reproducibility, but
|> your load command is bypassing that for us.

The objects loaded from .RData took hours of simulating and it's out
of the question to run them again inside Rmarkdown.  Though the script
used in the creation of .RData is reproducable, perhaps it would be
clearer for me to have saved the objects to a file by a different
name.

Is there a better way to do that??



|> On August 23, 2018 2:15:19 AM PDT, Patrick Connolly <[hidden email]> wrote:
|> >I'm having difficulty getting plots into ioslides.  It seems to me
|> >that the scale is completely out, but I can't figure out what to do
|> >about it.  Whatever I try, I get the title slide, then a second with a
|> >horizontal line and a vertical line in the bottom right corner.  It
|> >looks like a badly scaled plot about 25 times the size of the plotting
|> >area, so only a fragment is visible.
|> >
|> >This is the code I've tried:
|> >
|> >---
|> >title: "Barking up the wrong tree"
|> >author: "Patrick Connolly"
|> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
|> >output: ioslides_presentation
|> >---
|> >
|> >```{r global_options, echo=FALSE}
|> >knitr::opts_chunk$set(tidy=TRUE,
|> >                      warning=FALSE,
|> >                      message=FALSE,
|> >                      cache=FALSE,
|> >                      dpi=600)
|> >```
|> >
|> >```{r use these functions, echo= FALSE}
|> >  load(".RData") ## code for 6 plotting functions
|> >
|> >``
|> >## 6 different Trees
|> >
|> >```{r 6 different Trees, echo = FALSE, messages=FALSE, fig.width = 7,
|> >fig.height = 5}
|> >
|> >###  par(mfrow = c(2, 3))
|> >plot1()
|> >plot2()
|> >plot3()
|> >plot4()
|> >plot5()
|> >plot6()
|> >}
|> >```
|> >
|> >If I run the plot functions in the Console, it all works and displays
|> >correctly in Rstudiio's plot panel, even the mfrow bit.  But I haven't
|> >worked out how to include the code into Rmarkdown.  I thought it might
|> >be less taxing to not try putting the 6 plots on the same slide, but
|> >it makes no difference when I commented out the mfrow bit.
|> >
|> >I'm not very familiar with the workings of Markdown or Rstudio, but it
|> >does seem strange to me that I need to specifically load the global
|> >environment otherwise it's not visible.  Is that to be expected?
|> >
|> >Ideas welcome, particularly about scaling.
|>
|> --
|> Sent from my phone. Please excuse my brevity.

--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.  
   ___    Patrick Connolly  
 {~._.~}                   Great minds discuss ideas    
 _( Y )_           Average minds discuss events
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)                        ..... Eleanor Roosevelt
         
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Jeff Newmiller
a) Keep the mailing list in the conversation... someone else may have useful input, and others may benefit from reading the discussion.

b) If the issue can be reproduced on your end with something like a basic plot(mpg~disk, data=mtcars) call, then you should use that instead of your complicated example. If the problem only appears when you use certain plotting functions hidden inside your plot1 through plot6 functions, we can't tell that from here. Sorting that out is part of making your example minimal as the Posting Guide requests.

c) If you can only reproduce with certain data, then you can use dput to give us the necessary data.[1][2] It is up to you to determine what the minimal data needed to demo the problem is, but we don't want to sift through some large data blob only to find out that it was not relevant so you need to do that.

d) Interactions with data files are hard to make reproducible on someone else's computer... saving data with different filenames will not help fix that problem.

e) Note that this is the R-help mailing list, not the RStudio-help mailing list nor the rmarkdown-package-help mailing list. We can and often do provide help on using contributed packages anyway, but you should be aware that not everyone here uses RStudio so doing your best to provide a reproducible example is in your interest if you want readers to consider your question on topic.

There are many discussions online of how to communicate R examples, such as [1][2][3]. In particular I think [3] is useful because it forces you to confirm that the example will run in a fresh R environment which is the first step to insuring it will run on our computers and we can dig into the problem. in this case you could use it to help confirm that your R code should work for us without the rmarkdown.

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette)


On August 24, 2018 3:13:17 AM PDT, Patrick Connolly <[hidden email]> wrote:

>On Thu, 23-Aug-2018 at 07:23AM -0700, Jeff Newmiller wrote:
>
>|> This is not reproducible because you have not provided the plot
>|> code or sample data. Output of sessionInfo would probably be
>|> appropriate as well.
>
>I took it as read that the plotting functions themselves aren't an
>issue since they operate as intended outside of the Rmarkdown
>space. Any function that uses the function plot() successfully will
>do.  I was trying to ascertain how I should be setting up the scaling.
>
>|> As to whether needing to load objects is typical... yes, rmarkdown
>|> runs from a fresh environment to emphasize reproducibility, but
>|> your load command is bypassing that for us.
>
>The objects loaded from .RData took hours of simulating and it's out
>of the question to run them again inside Rmarkdown.  Though the script
>used in the creation of .RData is reproducable, perhaps it would be
>clearer for me to have saved the objects to a file by a different
>name.
>
>Is there a better way to do that??
>
>
>
>|> On August 23, 2018 2:15:19 AM PDT, Patrick Connolly
><[hidden email]> wrote:
>|> >I'm having difficulty getting plots into ioslides.  It seems to me
>|> >that the scale is completely out, but I can't figure out what to do
>|> >about it.  Whatever I try, I get the title slide, then a second
>with a
>|> >horizontal line and a vertical line in the bottom right corner.  It
>|> >looks like a badly scaled plot about 25 times the size of the
>plotting
>|> >area, so only a fragment is visible.
>|> >
>|> >This is the code I've tried:
>|> >
>|> >---
>|> >title: "Barking up the wrong tree"
>|> >author: "Patrick Connolly"
>|> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
>|> >output: ioslides_presentation
>|> >---
>|> >
>|> >```{r global_options, echo=FALSE}
>|> >knitr::opts_chunk$set(tidy=TRUE,
>|> >                      warning=FALSE,
>|> >                      message=FALSE,
>|> >                      cache=FALSE,
>|> >                      dpi=600)
>|> >```
>|> >
>|> >```{r use these functions, echo= FALSE}
>|> >  load(".RData") ## code for 6 plotting functions
>|> >
>|> >``
>|> >## 6 different Trees
>|> >
>|> >```{r 6 different Trees, echo = FALSE, messages=FALSE, fig.width =
>7,
>|> >fig.height = 5}
>|> >
>|> >###  par(mfrow = c(2, 3))
>|> >plot1()
>|> >plot2()
>|> >plot3()
>|> >plot4()
>|> >plot5()
>|> >plot6()
>|> >}
>|> >```
>|> >
>|> >If I run the plot functions in the Console, it all works and
>displays
>|> >correctly in Rstudiio's plot panel, even the mfrow bit.  But I
>haven't
>|> >worked out how to include the code into Rmarkdown.  I thought it
>might
>|> >be less taxing to not try putting the 6 plots on the same slide,
>but
>|> >it makes no difference when I commented out the mfrow bit.
>|> >
>|> >I'm not very familiar with the workings of Markdown or Rstudio, but
>it
>|> >does seem strange to me that I need to specifically load the global
>|> >environment otherwise it's not visible.  Is that to be expected?
>|> >
>|> >Ideas welcome, particularly about scaling.
>|>
>|> --
>|> Sent from my phone. Please excuse my brevity.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Patrick Connolly-4
In reply to this post by Jeff Newmiller
I've simplified it so that it's reproducible:


---
title: "Barking up the wrong tree"
author: "Patrick Connolly"
date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
output:
  ioslides_presentation: default
  slidy_presentation: default
  beamer_presentation: default
---

```{r global_options, echo=FALSE}
knitr::opts_chunk$set(tidy=TRUE,
                      warning=FALSE,
                      message=FALSE,
                      cache=FALSE,
                      dpi = 300)
         
```
## 6 different Regression Trees

```{r 6 different Regression Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}

 par(mfrow = c(2, 3))
plot(1:10)
plot(12:4)
plot(seq(0, 800))
plot(-100:-900)
plot(12:50)
plot(90:54)
```

I've tried it on a different machine which gives a slightly more
informative message:

X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 could not be loaded

That seems to be associated with the Cairo plotting device which isn't
necessary with pdf devices which I normally use, nor, it would seem by
the plot pane in Rstudio.  Consequently, running the plot code itself
works fine, but if is to be incorporated in HTML, we run into the Cairo
issue, Looking into that one, it appears something has been orphaned
for a couple of years.  If anyone has information about that, I'd be
interested.

TIA


-------------

 version 3.5.0 (2018-04-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /home/pat/local/R-3.5.0/lib/libRblas.so
LAPACK: /home/pat/local/R-3.5.0/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_NZ.UTF-8       LC_NUMERIC=C               LC_TIME=en_NZ.UTF-8      
 [4] LC_COLLATE=en_NZ.UTF-8     LC_MONETARY=en_NZ.UTF-8    LC_MESSAGES=en_NZ.UTF-8  
 [7] LC_PAPER=en_NZ.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C      

attached base packages:
[1] utils     stats     grDevices graphics  methods   base    

other attached packages:
[1] sp_1.3-1        lattice_0.20-35

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17     knitr_1.20       bindr_0.1.1      magrittr_1.5     tidyselect_0.2.4 munsell_0.5.0  
 [7] colorspace_1.3-2 xtable_1.8-2     R6_2.2.2         rlang_0.2.1      stringr_1.3.1    plyr_1.8.4      
[13] dplyr_0.7.6      tools_3.5.0      grid_3.5.0       htmltools_0.3.6  crosstalk_1.0.0  rprojroot_1.3-2
[19] yaml_2.1.19      leaflet_2.0.1    assertthat_0.2.0 digest_0.6.15    tibble_1.4.2     bindrcpp_0.2.2  
[25] shiny_1.1.0      purrr_0.2.5      later_0.7.3      htmlwidgets_1.2  promises_1.0.1   evaluate_0.10.1
[31] glue_1.2.0       mime_0.5         rmarkdown_1.10   stringi_1.2.3    compiler_3.5.0   pillar_1.2.3    
[37] backports_1.1.2  scales_0.5.0     httpuv_1.4.4.2   pkgconfig_2.0.1
>



On Thu, 23-Aug-2018 at 07:23AM -0700, Jeff Newmiller wrote:

|> This is not reproducible because you have not provided the plot code or sample data. Output of sessionInfo would probably be appropriate as well.
|>
|> As to whether needing to load objects is typical... yes, rmarkdown runs from a fresh environment to emphasize reproducibility, but your load command is bypassing that for us.
|>
|> On August 23, 2018 2:15:19 AM PDT, Patrick Connolly <[hidden email]> wrote:
|> >I'm having difficulty getting plots into ioslides.  

[...]


--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.  
   ___    Patrick Connolly  
 {~._.~}                   Great minds discuss ideas    
 _( Y )_           Average minds discuss events
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)                        ..... Eleanor Roosevelt
         
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Duncan Murdoch-2
On 25/08/2018 6:21 AM, Patrick Connolly wrote:

> ---
> title: "Barking up the wrong tree"
> author: "Patrick Connolly"
> date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
> output:
>    ioslides_presentation: default
>    slidy_presentation: default
>    beamer_presentation: default
> ---
>
> ```{r global_options, echo=FALSE}
> knitr::opts_chunk$set(tidy=TRUE,
>                        warning=FALSE,
>                        message=FALSE,
>                        cache=FALSE,
>                        dpi = 300)

Drop the dpi setting and it will work fine.

Duncan Murdoch

>          
> ```
> ## 6 different Regression Trees
>
> ```{r 6 different Regression Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}
>
>   par(mfrow = c(2, 3))
> plot(1:10)
> plot(12:4)
> plot(seq(0, 800))
> plot(-100:-900)
> plot(12:50)
> plot(90:54)
> ```

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Patrick Connolly-4
On Sat, 25-Aug-2018 at 07:53AM -0400, Duncan Murdoch wrote:

|> On 25/08/2018 6:21 AM, Patrick Connolly wrote:
|> >---
|> >title: "Barking up the wrong tree"
|> >author: "Patrick Connolly"
|> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
|> >output:
|> >   ioslides_presentation: default
|> >   slidy_presentation: default
|> >   beamer_presentation: default
|> >---
|> >
|> >```{r global_options, echo=FALSE}
|> >knitr::opts_chunk$set(tidy=TRUE,
|> >                       warning=FALSE,
|> >                       message=FALSE,
|> >                       cache=FALSE,
|> >                       dpi = 300)
|>
|> Drop the dpi setting and it will work fine.

Still doesn't avoid what I think is the issue with Cairo

   Error in axis(side = side, at = at, labels = labels, ...) : X11
  font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12
  could not be loaded Calls: <Anonymous> ... plot.default -> localAxis
  -> Axis -> Axis.default -> axis

  Execution halted


For interactive plotting, Rstudio plots those 6 plots on one page so
no issue is apparent, as it will if I use a pdf device within ESS.
However, when plotting interactively in ESS, a basic font is used for
the labels which is OK for preliminary quick look.  No error message
is shown, but I suspect that it is defaulting to a crude font because
the helvetica font is not available.

It appears to me that the font problem doesn't arise with Rstudio
unless the desired output is ioslides.  Which brings us back to the
issue with Cairo.  There are lots of hits when I search for
configuring fonts, Cairo and R but I've not found anything I can use.

I would appreciate pointers where I can find useful information.

Thank you.

|>
|> Duncan Murdoch
|>
|> >```
|> >## 6 different Regression Trees
|> >
|> >```{r 6 different Regression Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}
|> >
|> >  par(mfrow = c(2, 3))
|> >plot(1:10)
|> >plot(12:4)
|> >plot(seq(0, 800))
|> >plot(-100:-900)
|> >plot(12:50)
|> >plot(90:54)
|> >```

--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.  
   ___    Patrick Connolly  
 {~._.~}                   Great minds discuss ideas    
 _( Y )_           Average minds discuss events
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)                        ..... Eleanor Roosevelt
         
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Duncan Murdoch-2
On 25/08/2018 7:37 PM, Patrick Connolly wrote:

> On Sat, 25-Aug-2018 at 07:53AM -0400, Duncan Murdoch wrote:
>
> |> On 25/08/2018 6:21 AM, Patrick Connolly wrote:
> |> >---
> |> >title: "Barking up the wrong tree"
> |> >author: "Patrick Connolly"
> |> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
> |> >output:
> |> >   ioslides_presentation: default
> |> >   slidy_presentation: default
> |> >   beamer_presentation: default
> |> >---
> |> >
> |> >```{r global_options, echo=FALSE}
> |> >knitr::opts_chunk$set(tidy=TRUE,
> |> >                       warning=FALSE,
> |> >                       message=FALSE,
> |> >                       cache=FALSE,
> |> >                       dpi = 300)
> |>
> |> Drop the dpi setting and it will work fine.
>
> Still doesn't avoid what I think is the issue with Cairo
>
>     Error in axis(side = side, at = at, labels = labels, ...) : X11
>    font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12
>    could not be loaded Calls: <Anonymous> ... plot.default -> localAxis
>    -> Axis -> Axis.default -> axis
>
>    Execution halted
>
>
> For interactive plotting, Rstudio plots those 6 plots on one page so
> no issue is apparent, as it will if I use a pdf device within ESS.

So use RStudio, don't use ESS.

> However, when plotting interactively in ESS, a basic font is used for
> the labels which is OK for preliminary quick look.  No error message
> is shown, but I suspect that it is defaulting to a crude font because
> the helvetica font is not available.
>
> It appears to me that the font problem doesn't arise with Rstudio
> unless the desired output is ioslides.  Which brings us back to the
> issue with Cairo.  There are lots of hits when I search for
> configuring fonts, Cairo and R but I've not found anything I can use.
>

I don't see a font problem in MacOS.  I don't think you've stated what
system you are using (but I may have missed it).

Duncan Murdoch

> I would appreciate pointers where I can find useful information.
>
> Thank you.
>
> |>
> |> Duncan Murdoch
> |>
> |> >```
> |> >## 6 different Regression Trees
> |> >
> |> >```{r 6 different Regression Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}
> |> >
> |> >  par(mfrow = c(2, 3))
> |> >plot(1:10)
> |> >plot(12:4)
> |> >plot(seq(0, 800))
> |> >plot(-100:-900)
> |> >plot(12:50)
> |> >plot(90:54)
> |> >```
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Jeff Newmiller
a) Duncan, he provided sessionInfo below his reprex.

b) Patrick: you appear to be trying to use a common file to generate multiple output formats. I will caution you that I have found considerable disappointment in trying that, and suggest that you focus your efforts on one output format for each Rmd file.

c) You can add out.width="100%" and out.height="100%" to your chunk to fix the scaling problem. This method is HTML-specific... you would need different strings for LaTeX output.

d) Note that the help files for the rmarkdown output functions are often very interesting. e.g.

?rmarkdown::ioslides_presentation

On August 25, 2018 5:10:14 PM PDT, Duncan Murdoch <[hidden email]> wrote:

>On 25/08/2018 7:37 PM, Patrick Connolly wrote:
>> On Sat, 25-Aug-2018 at 07:53AM -0400, Duncan Murdoch wrote:
>>
>> |> On 25/08/2018 6:21 AM, Patrick Connolly wrote:
>> |> >---
>> |> >title: "Barking up the wrong tree"
>> |> >author: "Patrick Connolly"
>> |> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
>> |> >output:
>> |> >   ioslides_presentation: default
>> |> >   slidy_presentation: default
>> |> >   beamer_presentation: default
>> |> >---
>> |> >
>> |> >```{r global_options, echo=FALSE}
>> |> >knitr::opts_chunk$set(tidy=TRUE,
>> |> >                       warning=FALSE,
>> |> >                       message=FALSE,
>> |> >                       cache=FALSE,
>> |> >                       dpi = 300)
>> |>
>> |> Drop the dpi setting and it will work fine.
>>
>> Still doesn't avoid what I think is the issue with Cairo
>>
>>     Error in axis(side = side, at = at, labels = labels, ...) : X11
>>    font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size
>12
>>    could not be loaded Calls: <Anonymous> ... plot.default ->
>localAxis
>>    -> Axis -> Axis.default -> axis
>>
>>    Execution halted
>>
>>
>> For interactive plotting, Rstudio plots those 6 plots on one page so
>> no issue is apparent, as it will if I use a pdf device within ESS.
>
>So use RStudio, don't use ESS.
>
>> However, when plotting interactively in ESS, a basic font is used for
>> the labels which is OK for preliminary quick look.  No error message
>> is shown, but I suspect that it is defaulting to a crude font because
>> the helvetica font is not available.
>>
>> It appears to me that the font problem doesn't arise with Rstudio
>> unless the desired output is ioslides.  Which brings us back to the
>> issue with Cairo.  There are lots of hits when I search for
>> configuring fonts, Cairo and R but I've not found anything I can use.
>>
>
>I don't see a font problem in MacOS.  I don't think you've stated what
>system you are using (but I may have missed it).
>
>Duncan Murdoch
>
>> I would appreciate pointers where I can find useful information.
>>
>> Thank you.
>>
>> |>
>> |> Duncan Murdoch
>> |>
>> |> >```
>> |> >## 6 different Regression Trees
>> |> >
>> |> >```{r 6 different Regression Trees, echo = FALSE, messages=FALSE,
>fig.width = 7, fig.height = 5}
>> |> >
>> |> >  par(mfrow = c(2, 3))
>> |> >plot(1:10)
>> |> >plot(12:4)
>> |> >plot(seq(0, 800))
>> |> >plot(-100:-900)
>> |> >plot(12:50)
>> |> >plot(90:54)
>> |> >```
>>

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Patrick Connolly-4
In reply to this post by Duncan Murdoch-2
On Sat, 25-Aug-2018 at 08:10PM -0400, Duncan Murdoch wrote:

|> On 25/08/2018 7:37 PM, Patrick Connolly wrote:
|> >On Sat, 25-Aug-2018 at 07:53AM -0400, Duncan Murdoch wrote:
|> >
|> >|> On 25/08/2018 6:21 AM, Patrick Connolly wrote:
|> >|> >---
|> >|> >title: "Barking up the wrong tree"
|> >|> >author: "Patrick Connolly"
|> >|> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
|> >|> >output:
|> >|> >   ioslides_presentation: default
|> >|> >   slidy_presentation: default
|> >|> >   beamer_presentation: default
|> >|> >---
|> >|> >
|> >|> >```{r global_options, echo=FALSE}
|> >|> >knitr::opts_chunk$set(tidy=TRUE,
|> >|> >                       warning=FALSE,
|> >|> >                       message=FALSE,
|> >|> >                       cache=FALSE,
|> >|> >                       dpi = 300)
|> >|>
|> >|> Drop the dpi setting and it will work fine.
|> >
|> >Still doesn't avoid what I think is the issue with Cairo
|> >
|> >    Error in axis(side = side, at = at, labels = labels, ...) : X11
|> >   font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12
|> >   could not be loaded Calls: <Anonymous> ... plot.default -> localAxis
|> >   -> Axis -> Axis.default -> axis
|> >
|> >   Execution halted
|> >
|> >
|> >For interactive plotting, Rstudio plots those 6 plots on one page so
|> >no issue is apparent, as it will if I use a pdf device within ESS.
|>
|> So use RStudio, don't use ESS.

I'm using Rstudio to try to output ioslides which runs into the font
problem which doesn't arise when plotting to the plot pane.  RStudio's
no advantage when the objective is ioslides.  That observation gives
rise to my hypothesis that to produce ioslides, Cairo is utilized in
ways incomprehensible to me.

|>
|> >However, when plotting interactively in ESS, a basic font is used for
|> >the labels which is OK for preliminary quick look.  No error message
|> >is shown, but I suspect that it is defaulting to a crude font because
|> >the helvetica font is not available.
|> >
|> >It appears to me that the font problem doesn't arise with Rstudio
|> >unless the desired output is ioslides.  Which brings us back to the
|> >issue with Cairo.  There are lots of hits when I search for
|> >configuring fonts, Cairo and R but I've not found anything I can use.
|> >
|>
|> I don't see a font problem in MacOS.  I don't think you've stated
|> what system you are using (but I may have missed it).

It has something to do with X11 which I guess MacOS doesn't use.

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /home/pat/local/R-3.5.0/lib/libRblas.so
LAPACK: /home/pat/local/R-3.5.0/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_NZ.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_NZ.UTF-8        LC_COLLATE=en_NZ.UTF-8    
 [5] LC_MONETARY=en_NZ.UTF-8    LC_MESSAGES=en_NZ.UTF-8  
 [7] LC_PAPER=en_NZ.UTF-8       LC_NAME=C                
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C      

attached base packages:
[1] utils     stats     grDevices graphics  methods   base    

other attached packages:
[1] lattice_0.20-35

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17     bindr_0.1.1      magrittr_1.5     tidyselect_0.2.4
 [5] munsell_0.5.0    colorspace_1.3-2 xtable_1.8-2     R6_2.2.2        
 [9] rlang_0.2.1      plyr_1.8.4       dplyr_0.7.6      tools_3.5.0    
[13] grid_3.5.0       htmltools_0.3.6  crosstalk_1.0.0  leaflet_2.0.1  
[17] assertthat_0.2.0 digest_0.6.15    tibble_1.4.2     bindrcpp_0.2.2  
[21] shiny_1.1.0      purrr_0.2.5      later_0.7.3      htmlwidgets_1.2
[25] promises_1.0.1   glue_1.2.0       mime_0.5         compiler_3.5.0  
[29] pillar_1.2.3     scales_0.5.0     httpuv_1.4.4.2   pkgconfig_2.0.1


|>
|> Duncan Murdoch
|>
|> >I would appreciate pointers where I can find useful information.
|> >
|> >Thank you.
|> >
|> >|>
|> >|> Duncan Murdoch
|> >|>
|> >|> >```
|> >|> >## 6 different Regression Trees
|> >|> >
|> >|> >```{r 6 different Regression Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}
|> >|> >
|> >|> >  par(mfrow = c(2, 3))
|> >|> >plot(1:10)
|> >|> >plot(12:4)
|> >|> >plot(seq(0, 800))
|> >|> >plot(-100:-900)
|> >|> >plot(12:50)
|> >|> >plot(90:54)
|> >|> >```
|> >

--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.  
   ___    Patrick Connolly  
 {~._.~}                   Great minds discuss ideas    
 _( Y )_           Average minds discuss events
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)                        ..... Eleanor Roosevelt
         
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Plots in ioslides and R markdown

Duncan Murdoch-2
On 26/08/2018 4:40 AM, Patrick Connolly wrote:

> On Sat, 25-Aug-2018 at 08:10PM -0400, Duncan Murdoch wrote:
>
> |> On 25/08/2018 7:37 PM, Patrick Connolly wrote:
> |> >On Sat, 25-Aug-2018 at 07:53AM -0400, Duncan Murdoch wrote:
> |> >
> |> >|> On 25/08/2018 6:21 AM, Patrick Connolly wrote:
> |> >|> >---
> |> >|> >title: "Barking up the wrong tree"
> |> >|> >author: "Patrick Connolly"
> |> >|> >date: "`r format(Sys.time(), '%a %d/%m/%Y %H:%M')`"
> |> >|> >output:
> |> >|> >   ioslides_presentation: default
> |> >|> >   slidy_presentation: default
> |> >|> >   beamer_presentation: default
> |> >|> >---
> |> >|> >
> |> >|> >```{r global_options, echo=FALSE}
> |> >|> >knitr::opts_chunk$set(tidy=TRUE,
> |> >|> >                       warning=FALSE,
> |> >|> >                       message=FALSE,
> |> >|> >                       cache=FALSE,
> |> >|> >                       dpi = 300)
> |> >|>
> |> >|> Drop the dpi setting and it will work fine.
> |> >
> |> >Still doesn't avoid what I think is the issue with Cairo
> |> >
> |> >    Error in axis(side = side, at = at, labels = labels, ...) : X11
> |> >   font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12
> |> >   could not be loaded Calls: <Anonymous> ... plot.default -> localAxis
> |> >   -> Axis -> Axis.default -> axis
> |> >
> |> >   Execution halted
> |> >
> |> >
> |> >For interactive plotting, Rstudio plots those 6 plots on one page so
> |> >no issue is apparent, as it will if I use a pdf device within ESS.
> |>
> |> So use RStudio, don't use ESS.
>
> I'm using Rstudio to try to output ioslides which runs into the font
> problem which doesn't arise when plotting to the plot pane.  RStudio's
> no advantage when the objective is ioslides.  That observation gives
> rise to my hypothesis that to produce ioslides, Cairo is utilized in
> ways incomprehensible to me.

Since that error happens during the axis() call, it's related to the
graphics device that is being used.  That would be different for an
ioslides document than it is for interactive display.  On my system (and
I think on all systems) the png() device is used for ioslides.

If you run debug(png) then rmarkdown::render( <your Rmd file> ), you'll
see what options are being passed to png.  On my system, it is called
with no arguments except a filename, so it uses the defaults for all
other arguments.  That means the "type" argument eventually gets set to
"quartz".  Yours will be different, but I don't know what it will get.
Maybe you can choose something different than the default by setting
options("bitmapType").

Duncan Murdoch

>
> |>
> |> >However, when plotting interactively in ESS, a basic font is used for
> |> >the labels which is OK for preliminary quick look.  No error message
> |> >is shown, but I suspect that it is defaulting to a crude font because
> |> >the helvetica font is not available.
> |> >
> |> >It appears to me that the font problem doesn't arise with Rstudio
> |> >unless the desired output is ioslides.  Which brings us back to the
> |> >issue with Cairo.  There are lots of hits when I search for
> |> >configuring fonts, Cairo and R but I've not found anything I can use.
> |> >
> |>
> |> I don't see a font problem in MacOS.  I don't think you've stated
> |> what system you are using (but I may have missed it).
>
> It has something to do with X11 which I guess MacOS doesn't use.
>
>> sessionInfo()
> R version 3.5.0 (2018-04-23)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 14.04.5 LTS
>
> Matrix products: default
> BLAS: /home/pat/local/R-3.5.0/lib/libRblas.so
> LAPACK: /home/pat/local/R-3.5.0/lib/libRlapack.so
>
> locale:
>   [1] LC_CTYPE=en_NZ.UTF-8       LC_NUMERIC=C
>   [3] LC_TIME=en_NZ.UTF-8        LC_COLLATE=en_NZ.UTF-8
>   [5] LC_MONETARY=en_NZ.UTF-8    LC_MESSAGES=en_NZ.UTF-8
>   [7] LC_PAPER=en_NZ.UTF-8       LC_NAME=C
>   [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] utils     stats     grDevices graphics  methods   base
>
> other attached packages:
> [1] lattice_0.20-35
>
> loaded via a namespace (and not attached):
>   [1] Rcpp_0.12.17     bindr_0.1.1      magrittr_1.5     tidyselect_0.2.4
>   [5] munsell_0.5.0    colorspace_1.3-2 xtable_1.8-2     R6_2.2.2
>   [9] rlang_0.2.1      plyr_1.8.4       dplyr_0.7.6      tools_3.5.0
> [13] grid_3.5.0       htmltools_0.3.6  crosstalk_1.0.0  leaflet_2.0.1
> [17] assertthat_0.2.0 digest_0.6.15    tibble_1.4.2     bindrcpp_0.2.2
> [21] shiny_1.1.0      purrr_0.2.5      later_0.7.3      htmlwidgets_1.2
> [25] promises_1.0.1   glue_1.2.0       mime_0.5         compiler_3.5.0
> [29] pillar_1.2.3     scales_0.5.0     httpuv_1.4.4.2   pkgconfig_2.0.1
>
>
> |>
> |> Duncan Murdoch
> |>
> |> >I would appreciate pointers where I can find useful information.
> |> >
> |> >Thank you.
> |> >
> |> >|>
> |> >|> Duncan Murdoch
> |> >|>
> |> >|> >```
> |> >|> >## 6 different Regression Trees
> |> >|> >
> |> >|> >```{r 6 different Regression Trees, echo = FALSE, messages=FALSE, fig.width = 7, fig.height = 5}
> |> >|> >
> |> >|> >  par(mfrow = c(2, 3))
> |> >|> >plot(1:10)
> |> >|> >plot(12:4)
> |> >|> >plot(seq(0, 800))
> |> >|> >plot(-100:-900)
> |> >|> >plot(12:50)
> |> >|> >plot(90:54)
> |> >|> >```
> |> >
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.