Add an (SVG-) image to an existing graph in R - image

I'd like to an an image (ideally an SVG) as an inset to an existing graph in R and put a black border around the image.
Is that possible with base-functions in R? Do I need packages for that?

Maybe the grImport package is what you are looking for ? It only seems to allow to import Posctscript files, however.
You can find two vignettes files on the package web page, which should help you learn how to use it.

Convert your SVG to PostScript, then you can do all this good stuff:
http://www.stat.auckland.ac.nz/~paul/Talks/import.pdf
If there's an easier way to convert from SVG to the RGML format mentioned there, that would be a better option.

Related

Can I set an image, pixel by pixel, in Apps Script?

Preferably, I'd like to use an array, iterating over each pixel and setting the R G B values.
And I don't think that I can use HTML canvas in any way. I'm hoping to build it right on top of a Google Doc without additional libraries or references to external websites.
Everything I have found on the Image Class, type is about positioning or resizing, but not helpful for stating the image.
ImageItem .setImage() looks promising, but is not particularly descriptive.
You can implement your own encoding algorithm (or migrate someone else's) and transform your pixels array into an image blob compatible with the ImageItem.setImage() method.

Cropping SVG to range in Inkscape?

Say I have a range – something like a 400x400 rectangle at 60, 60 – which is dynamically generated by a separate program. I'm wondering how it's possible to crop my document to that range in the command line?
Everything I've read has suggested I'd need to add a rectangle to the document, resize the document to that rectangle (resize to selection), and then remove the rectangle.
But I'm having trouble with adding and removing that rectangle. I found the ToolRect verb, but I can't seem to find anything related to actually drawing that rectangle (or removing it).
So, am I doing this wrong or is there just no way to add (and select) the rectangle using only the command line? Using another program is also fine, but I haven't had much luck with that (I couldn't get the python modules installed for the only possibly helpful thing I found..).
In this email discussion from 2012, someone said:
There is no way to pass parameters to verbs (with the current
implementation, they don't take parameters by design).
In case they add this capability later, the required verbs to crop the page would be:
EditSelectAll
SelectionGroup
ToolRect (requires parameters, i.e. where to crop)
EditSelectAll
ObjectSetClipPath
FitCanvasToDrawing
FileVacuum
FileSaveAs (requires a parameter, so that we don't have to overwrite the original)
Since Inkscape can edit any valid SVG, I'd rather look into other available SVG libraries, like this one for Python.
If you are OK with rasterising your image, take a look at this question. Inkscape unfortunately ignores the --export-area option when exporting to svg or pdf.
My – admittedly, unsatisfying – solution was to create a separate program to add a viewbox to the SVG text.
The program I made was implemented into a separate part of my project, so I don't have a good command line version, but if you plan on making one yourself, whatever XML editing library you have for your language of choice should be all you need. I used xmldom for Node.js with relative ease.

Corel Draw X5 Slicing

I have to slice from "cdr" file to HTML. I search on the web, but i didn't find anything on how to do that.
Does anybody know a tutorial on how to slice from CorelDraw to Html?
It's that even possible or should i convert it somehow in PSD?
Thanks.
Go to file->export->and select psd option and export it, and slice the images using photoshop then use it in html.
If you need layers , go to corel draw tools ->object manager there you have arrange your design in layer format then export it.

program/library to read photoshop gradient .grd file

Does anybody know program or library that can read the photoshop gradient .grd files or the file format because currently I need to export the gradient in Photoshop to another format like svg gradient.
A document describing the Photoshop Gradients File Format has been mentioned in this PS-Scripts forum:
http://www.ps-scripts.com/bb/viewtopic.php?f=2&t=4925
HTH...
The cptutils package can convert grd to svg (and many other formats). I you just want to convert a couple of files the possibly the online version will meet your needs.
You might try using Gimp; for which this article suggest a free add-on under "Conversion options" (which I have not tried).
http://gitorious.org/re-lab/graphics/trees/master/photoshop/grd is what you are looking for

Latex - Is it possible to have text on top of images?

I want to create something like a leaflet/magazine using Latex. Is it possible to place text on top of an image and style the text freely?
Any links to examples of something like this?
I usually do something like
\usepackage{tikz}
...
\begin{tikzpicture}
\draw (0, 0) node[inner sep=0] {\includegraphics[width=4cm]{imagefile.png}};
\draw (1, 1) node {Hello world};
\end{tikzpicture}
A very good toolset for manipulating images is pgf/TikZ pdf doc.
See \pgfimage for examples. It allows to mix text and image freely. There are many ways to do it. One of them is to use layers (p. 220 of pgfmanual). The pgf manual contains many simple examples, and is very precise.
Another solution is to use the lpic package: the homepage contains some examples.
You can find other examples for pfg and TikZ here and here for many impressive examples.
You can also define the text after the image and then offset it using negative vertical space. Because it follows after the image in the LaTeX source, it will be drawn on top of the image instead of underneath it.
\includegraphics[...]{...}
\vspace*{-20ex} % Tune this to the image height.
\begin{center}
Text
\end{center}
\vspace*{20ex} % The spacing above but without the minus.
Another solution is the textpos package which allows you to specify boxes at absolute positions on the page. The boxes can overlap, so you can put the figure in one box, and text in another box on top of it.
I realise that the question is old and answer is accepted, but for completeness would like to propose an alternative approach for making leaflets in LaTeX.
Specifically, the leaflet document style served me really well for this purpose.
A good blog post wrt background image can be found here. There are a couple of packages that are required to use in order to make the proposed approach work, but were not mentioned in the blog post:
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{transparent}
As already suggested, you can annotate the different parts of the figure using TikZ. However, sometimes it might even better to use numbers to reference the different parts and explain them in the figure caption.
To easily get the precise relative positions (which is often tedious) and to generate LaTeX code automatically, you could use the new web-based LaTeX Overlay Generator, which I built for such cases. This is just a small interactive tool, which helps you to find the right locations.
Another way to do this, admittedly not using LaTeX, would simply be to edit the image with photoshop or gimp or something like that. I guess your option in terms of typesetting mathematics might be fairly limited doing it this way.
Otherwise I'd endorse using tikz.
Are you sure you want to do it in LaTeX? Desktop publishing software might be more suited to your needs... Something like scribus might be easier than tikz in terms of learning curve, depending on what you want to do.
I'd like to add on to #midtiby's answer...
You can also specify the text position using a relative position, like so:
\usepackage{tikz}
...
\begin{tikzpicture}
\node[inner sep=0] (image) at (0,0) {\includegraphics[width=4cm]{imagefile.png}};
\node[above=0 of image] {Hello world};
\end{tikzpicture}

Resources