Zim

GNU R Plot Editor limitations

Asked by pvanb

I find this a very useful plugin. I have to suggestions that would i.m.h.o. improve it even further (but I have no clue how difficult to implement this).

1) currently it does not seem to be possible to set the size of the plot (using the fin parameter in the par function). It would be great to make this option. Preferably using the R syntax (to ensure proper scaling of all the graph elements, but otherwise via a similar interface as normal inserted images.

2) The plugin is especially powerful in that it is possible to use R code that extracts the data for the figure from a database (or any data source I guess). This means that if you update the database, it is possible to update the figure by simply right clicking on the image, select the GNU R plugin context menu and click OK in the plugin's dialogue.

What would this make even more fantastic is if there would be an option to update all figures in a notebook (or selected notes) at once without having to open the context menu for each figure separately. This would be very very useful in e.g., online reports.

Paulo

Question information

Language:
English Edit question
Status:
Answered
For:
Zim Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jaap Karssenberg (jaap.karssenberg) said :
#1

On Mon, Jun 13, 2011 at 4:50 PM, pvanb <<email address hidden>
> wrote:

> 1) currently it does not seem to be possible to set the size of the plot
> (using the fin parameter in the par function). It would be great to make
> this option. Preferably using the R syntax (to ensure proper scaling of all
> the graph elements, but otherwise via a similar interface as normal inserted
> images.
>

As I have no experience with GNU R I do not fully understand this issue. Zim
just embeds the image using the size GNU R produced it. Only thing the
plugin in does is add "png()" on top of the script and call "R". So if you
can write a R script that produces an image at a certain size when calling R
manually, it should work just as well in the plugin - unless you need to add
some parameters in the "png()" function - if that is the case please let me
know what parameters.

2) The plugin is especially powerful in that it is possible to use R code
> that extracts the data for the figure from a database (or any data source I
> guess). This means that if you update the database, it is possible to update
> the figure by simply right clicking on the image, select the GNU R plugin
> context menu and click OK in the plugin's dialogue.
>
> What would this make even more fantastic is if there would be an option to
> update all figures in a notebook (or selected notes) at once without having
> to open the context menu for each figure separately. This would be very very
> useful in e.g., online reports.
>

The plugin could be patched to add a menu option for that. You could also
write a simple shell script that call R for all the ".r" files in the
notebook and add that script as a "custom tool".

-- Jaap

Revision history for this message
pvanb (p-vanbreugel) said :
#2

Hi Jaap,

1) I see that my description was not correct. You can scale the image, but within limits, which are probably set by the image size. To give you an example:

op <- par(fin=c(6,3))
hist(islands)

the fin=c(x,y) argument in the par function sets the dimensions x and y of the figure (in inches), and it does work, but both x and y have a maximum.

So the scaling length and height is possible. To set the size of the image, you do indeed need to set parameters to the png() function. The argument to set the size of the image are:

png(filename =, width = 480, height = 480, units = "px"). Besides pixels, the units can be set to inches, cm or mm.

2) I guess I should be able figure out how to make this "custom tool" (I always thought I should figure out how to make use of this potentially very useful function). But the problem in this case is that I have many more r files in my notebook as attached files, but I would only want to update the ones created by the plugin to embed the images.

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) said :
#3

On Wed, Jun 15, 2011 at 10:31 AM, pvanb <
<email address hidden>> wrote:

> Question #161276 on Zim changed:
> https://answers.launchpad.net/zim/+question/161276
>
> Status: Answered => Open
>
> pvanb is still having a problem:
> Hi Jaap,
>
> 1) I see that my description was not correct. You can scale the image,
> but within limits, which are probably set by the image size. To give you
> an example:
>
> op <- par(fin=c(6,3))
> hist(islands)
>
> the fin=c(x,y) argument in the par function sets the dimensions x and y
> of the figure (in inches), and it does work, but both x and y have a
> maximum.
>
> So the scaling length and height is possible. To set the size of the
> image, you do indeed need to set parameters to the png() function. The
> argument to set the size of the image are:
>
> png(filename =, width = 480, height = 480, units = "px"). Besides
> pixels, the units can be set to inches, cm or mm.
>

Can you file a bug report describing this ? We can make the plugin check if
a png() function is used and if so remove it from the template.

2) I guess I should be able figure out how to make this "custom tool" (I
> always thought I should figure out how to make use of this potentially
> very useful function). But the problem in this case is that I have many
> more r files in my notebook as attached files, but I would only want to
> update the ones created by the plugin to embed the images.
>

So the script should check for R files that have a like named PNG file.

-- Jaap

Can you help with this problem?

Provide an answer of your own, or ask pvanb for more information if necessary.

To post a message you must log in.