Load svg, eps or png into graphics device?

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

Load svg, eps or png into graphics device?

Rainer M Krug-3

Hi

I have a package, which plots from the plantuml syntax (https://plantuml.com) graphs via a knitr engine, into a file, or into a graphics device (https://github.com/rkrug/plantuml).

I am using at the moment grImport for the eps import, but would like to cut down on dependencies.

Is there a way of bringing graphics files (png, sag, eps, …) into a graphics device in R?

Thanks,

Rainer






--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:       +41 (0)78 630 66 57
email:      [hidden email]
                [hidden email]
Skype:     RMkrug

PGP: 0x0F52F982

______________________________________________
[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: Load svg, eps or png into graphics device?

Abby Spurdle
If I understand your question correctly, you're already able to read
an EPS file.
So, essentially, you have an answer to your question.

Paul Murrell published an article on using raster graphics, in 2011.
https://journal.r-project.org/archive/2011-1/RJournal_2011-1_Murrell.pdf

I would assume there's been progress since then.
But I don't see the point here.
Writing what would otherwise be vector graphics to a raster-based
image file, and then reading it back into a vector graphics system,
would create unnecessary problems.


On Sat, Jun 20, 2020 at 2:56 AM Rainer M Krug <[hidden email]> wrote:

>
>
> Hi
>
> I have a package, which plots from the plantuml syntax (https://plantuml.com) graphs via a knitr engine, into a file, or into a graphics device (https://github.com/rkrug/plantuml).
>
> I am using at the moment grImport for the eps import, but would like to cut down on dependencies.
>
> Is there a way of bringing graphics files (png, sag, eps, …) into a graphics device in R?
>
> Thanks,
>
> Rainer
>
>
>
>
>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>
> Orcid ID: 0000-0002-7490-0066
>
> Department of Evolutionary Biology and Environmental Studies
> University of Zürich
> Office Y34-J-74
> Winterthurerstrasse 190
> 8075 Zürich
> Switzerland
>
> Office: +41 (0)44 635 47 64
> Cell:           +41 (0)78 630 66 57
> email:      [hidden email]
>                 [hidden email]
> Skype:     RMkrug
>
> PGP: 0x0F52F982
>
> ______________________________________________
> [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.

______________________________________________
[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: Load svg, eps or png into graphics device?

Paul Murrell-2
In reply to this post by Rainer M Krug-3
Hi

Do you mean you want to reduce *system requirements* ?  I'm not sure you
have many options.  Looking at the plantuml output format options, there
is ...

png via 'png', which requires libpng
svg via 'grImport2', which requires 'rsvg', which requires librsvg2
eps via 'grImport', which requires ghostscript

... and a number of other formats that cannot be read directly into R AFAIK.

The only option that does not require dependencies looks like the "txt"
format, which you could read in with readLines(), but I'm not sure you
want an ASCII art version :)

Paul

On 20/06/20 2:56 am, Rainer M Krug wrote:

>
> Hi
>
> I have a package, which plots from the plantuml syntax (https://plantuml.com) graphs via a knitr engine, into a file, or into a graphics device (https://github.com/rkrug/plantuml).
>
> I am using at the moment grImport for the eps import, but would like to cut down on dependencies.
>
> Is there a way of bringing graphics files (png, sag, eps, …) into a graphics device in R?
>
> Thanks,
>
> Rainer
>
>
>
>
>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>
> Orcid ID: 0000-0002-7490-0066
>
> Department of Evolutionary Biology and Environmental Studies
> University of Zürich
> Office Y34-J-74
> Winterthurerstrasse 190
> 8075 Zürich
> Switzerland
>
> Office: +41 (0)44 635 47 64
> Cell:       +41 (0)78 630 66 57
> email:      [hidden email]
> [hidden email]
> Skype:     RMkrug
>
> PGP: 0x0F52F982
>
> ______________________________________________
> [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.
>

--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[hidden email]
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
[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: Load svg, eps or png into graphics device?

Rainer M Krug-3


> On 21 Jun 2020, at 22:42, Paul Murrell <[hidden email]> wrote:
>
> Hi
>
> Do you mean you want to reduce *system requirements* ?

system requirements and package dependencies. Yes.

>  I'm not sure you have many options.

That was my impression as well, and that is why I asked here - possibly somebody has any smart idea.


>  Looking at the plantuml output format options, there is ...
>
> png via 'png', which requires libpng

Yup.

> svg via 'grImport2', which requires 'rsvg', which requires librsvg2

Tried it, but did not work as well as

> eps via 'grImport', which requires ghostscript

Which I am using for the vector graph.

>
> ... and a number of other formats that cannot be read directly into R AFAIK.
>
> The only option that does not require dependencies looks like the "txt" format, which you could read in with readLines(), but I'm not sure you want an ASCII art version :)

Actually, it could actually be an option if none of the above is installed. Kind of cascading, depending if installed: eps - sag - png - ASCII art.

Thanks,

Rainer


>
> Paul
>
> On 20/06/20 2:56 am, Rainer M Krug wrote:
>> Hi
>> I have a package, which plots from the plantuml syntax (https://plantuml.com) graphs via a knitr engine, into a file, or into a graphics device (https://github.com/rkrug/plantuml).
>> I am using at the moment grImport for the eps import, but would like to cut down on dependencies.
>> Is there a way of bringing graphics files (png, sag, eps, …) into a graphics device in R?
>> Thanks,
>> Rainer
>> --
>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>> Orcid ID: 0000-0002-7490-0066
>> Department of Evolutionary Biology and Environmental Studies
>> University of Zürich
>> Office Y34-J-74
>> Winterthurerstrasse 190
>> 8075 Zürich
>> Switzerland
>> Office: +41 (0)44 635 47 64
>> Cell:       +41 (0)78 630 66 57
>> email:      [hidden email]
>> [hidden email]
>> Skype:     RMkrug
>> PGP: 0x0F52F982
>> ______________________________________________
>> [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.
>
> --
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> [hidden email]
> http://www.stat.auckland.ac.nz/~paul/

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:       +41 (0)78 630 66 57
email:      [hidden email]
                [hidden email]
Skype:     RMkrug

PGP: 0x0F52F982




        [[alternative HTML version deleted]]

______________________________________________
[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: Load svg, eps or png into graphics device?

Rainer M Krug-3
In reply to this post by Abby Spurdle


> On 20 Jun 2020, at 01:30, Abby Spurdle <[hidden email]> wrote:
>
> If I understand your question correctly, you're already able to read
> an EPS file.
> So, essentially, you have an answer to your question.

Well - there are some dependencies (system as well as package dependencies) which I would like to cut down - that is why I am asking.
>
> Paul Murrell published an article on using raster graphics, in 2011.
> https://journal.r-project.org/archive/2011-1/RJournal_2011-1_Murrell.pdf
>
> I would assume there's been progress since then.
> But I don't see the point here.

Depending on the use, it might be better to have a raster or a vector representation. But I agree - in general, is vector better.


> Writing what would otherwise be vector graphics to a raster-based

No - plantuml can also produce png graphs - these are the ones I am using for the raster representation.

> image file, and then reading it back into a vector graphics system,
> would create unnecessary problems.

That one is true.


Thanks,

Rainer

>
>
> On Sat, Jun 20, 2020 at 2:56 AM Rainer M Krug <[hidden email]> wrote:
>>
>>
>> Hi
>>
>> I have a package, which plots from the plantuml syntax (https://plantuml.com) graphs via a knitr engine, into a file, or into a graphics device (https://github.com/rkrug/plantuml).
>>
>> I am using at the moment grImport for the eps import, but would like to cut down on dependencies.
>>
>> Is there a way of bringing graphics files (png, sag, eps, …) into a graphics device in R?
>>
>> Thanks,
>>
>> Rainer
>>
>>
>>
>>
>>
>>
>> --
>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
>>
>> Orcid ID: 0000-0002-7490-0066
>>
>> Department of Evolutionary Biology and Environmental Studies
>> University of Zürich
>> Office Y34-J-74
>> Winterthurerstrasse 190
>> 8075 Zürich
>> Switzerland
>>
>> Office: +41 (0)44 635 47 64
>> Cell:           +41 (0)78 630 66 57
>> email:      [hidden email]
>>                [hidden email]
>> Skype:     RMkrug
>>
>> PGP: 0x0F52F982
>>
>> ______________________________________________
>> [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.

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:       +41 (0)78 630 66 57
email:      [hidden email]
                [hidden email]
Skype:     RMkrug

PGP: 0x0F52F982




        [[alternative HTML version deleted]]

______________________________________________
[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.