R markdown - including an svg image with tooltips generated using RSVGTipsDevice package - r

I want to include an svg image in an .Rmd document. The svg is created using the RSVGTipsDevice package as I want the image to have some tooltips. The problem is that after the image has been included into the generated HTML document, the tooltips do not work anymore. Although they work properly when I open the svg in a browser (link to image, hover over red rectangle to see the tooltip).
http://www.gridhub.uni-bremen.de/public/pics/plot.svg
Here is the complete .Rmd code:
```{r}
library(RSVGTipsDevice)
devSVGTips("plot.svg", toolTipMode=1)
plot(0, type="n")
setSVGShapeToolTip("A rectangle","it is red")
rect(.1,.1,.4,.6, col='red')
dev.off()
```
![alt text](plot.svg)
The question is: How can I make the tooltips work?

Does my comment help? To be clear, the ![alt text](plot.svg) portion becomes <img src="plot.svg"> which is not a proper way to include svg. To prove this works, I've provided the source and its output.

Related

Bookdown - Add space between side by side figures using knitr::include_graphics

The recomended way to include existing images in bookdown is using knitr::include_graphics.
For example, to put two images side by side code will be something like:
```{r myfigure fig.show='hold', fig.align='center', out.width='50%', fig.cap = ""}
fig1_path <- paste0(fig_path,"image1.png")
fig2_path <- paste0(fig_path,"image2.png")
knitr::include_graphics(c(fig1_path, fig2_path))
```
However, this produces html and latex where the images are very close each other. It would be desirable to add some space/padding/margin between to look better.
For the html case, this is easy to fix because we can add some external css to control the space. However, for the latex output i don't have any decent solution yet.
Im thinking a portable workaround could be to add an extra empty image between or add lateral space to both images, but i prefer to hear better suggestions.

How do I export a ggplot as resizable image?

I'm working on a report with some coworkers in Google Docs (which will eventually be printed). We want to include some plots generated with ggplot. As we edit the document, the space for the images keeps changing slightly--often, we need to resize and/or change the aspect ratio of a plot slightly so that it fits on the page with the accompanying text.
Is there a way to export a ggplot object to an image that is resizable in the same way that plots can be resized in the Export dialog in RStudio?
Google Docs does not support SVG images--dropping an svg on the page simply opens the SVG itself (rather than adding it to the doc), so that's not an option.

Changing invisible (white font) output in RStudio theme `Cobalt`

I'm using R Studio's Cobalt theme, and I have found one case where in-line output in Rmd files is invisible (i.e. font is white on a white background). I would like to edit that font colour to anything visible.
Reproducible example below:
First set Editor Theme to Cobalt:
Then, a simple example of using str_view() from Hadley's R4DS, in an Rmd file:
x <- c("apple", "banana", "pear")
stringr::str_view(x, "an")
The output will render to visible HTML no problem, and the Viewer window also shows visible output:
But when if you run it as an in-line chunk (i.e. how a lot of my debugging takes place), we get some of the output as a white font on white background:
How can I edit that font colour for that particular output, so that it is visible?
I have already tried editing Cobalt here:
https://tmtheme-editor.herokuapp.com/#!/editor/theme/Cobalt
Following the advice from here:
https://towardsdatascience.com/customize-your-rstudio-theme-914cca8b04b1
Maybe it's late but i've a solution with same problem.You need to change foreground color of your preferred theme(or change html background)
Here is you can edit your preferred theme : https://tmtheme-editor.herokuapp.com
As you wrote upward,in most of dark themes foregrounds are whitish . Where you can edit in general tab .You should choose a bit darker foreground (for ex:#BEC0C2).
or
i couldn't find how to change html background in Cobalt theme but some other (ex: Material) theme allow us to change colors of popup Css
Sorry for my photo edits :D
Hopefully it will work ...
For anyone looking at this question, I've tried a lot of things, and honestly the easiest answer was to move the output of chunks out of the inline document, and move it to the console. Everything works after that:

How do I use markdown to generate a PDF will full background-color/image bleed?

I have a simple markdown document that has either a background color or background image defined in the stylesheet I'm using to render it. When I export to PDF (using marked.app, mou.app, markdown pro, Multimarkdown Composer etC), I'd like that background to be full-bleed on the page with no margin or padding (i.e. no surrounding whitespace), much like something you'd create in illustrator.
Here is an example. (Reference the cover page). This will be used solely for on-screen consumption so I'm not worried about printing.
Can anyone suggest how to do this or a mac app that can do this?
Thanks!

css issue while downloading png image from svg in nvd3

I have one line chart using nvd3.js . I want to download this chart in .png format.
I am using canvas and sending the canvas.toDataURL("image/png") to server and downloading the image, but the image is not in proper shape .it seems the css(nvd3.css) is not getting applied.
Any help will be really heplfull.
Thanks,
chandan
i have the same requirement and "example of how to export a png directly from an svg" solved my problem (internally it adopted svg-crowbar code. basically, you need to "explicitly set css style" for all svg element.

Resources