[R] Add png image outside plot borders

2011-09-18 Thread Amelia McNamara
I am trying to add a copyright disclaimer outside the plot borders of
some images I have created. I can use mtext() to add the written
portion, but I would like to have the Creative Commons license image
(http://en.wikipedia.org/wiki/File:Cc.logo.circle.svg) before the
text. I've found that I can plot a .png image inside the plot
boundaries using rasterImage() but I can't figure out how to do it
outside the boundaries.

Any help would be great. If you know unicode or Adobe Symbol encoding
for the CC logo, that might work too.

~Amelia McNamara
Statistics PhD student, UCLA

__
R-help@r-project.org mailing list
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.


Re: [R] Add png image outside plot borders

2011-09-18 Thread Amelia McNamara
If you run this, you'll see that I have some text at the bottom, but
the logo is within the plot borders.

plot(c(1.1, 2.3, 4.6), c(2.0, 1.6, 3.2), ylab=, xlab=)
mtext(X axis label, side=1, line=3)
mtext(Copyright statement, side=1, line=4, adj=0, cex=0.7)
library(png)
z - readPNG(Cc.logo.circle.png)
rasterImage(z, 1, 1.6, 1.2, 1.7)

I've tried doing things like

rasterImage(z, 1, 0.5, 1.2, 1)

but nothing shows up. The documentation for rasterImage() says that
the corner values have to be within the plot region. As I said before,
I want the logo to be down on the level of my copyright text, outside
the plot region.

Thanks!


On Sun, Sep 18, 2011 at 1:26 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 Hi Amelia,

 Can you give an example (using text where you want the CC is fine)?
 Two angles I would try would be A) changing the regions or related but
 more flexible (and hence complex) B) use grid of course if you're
 making these with, say, ggplot2, you're already in grid (but then
 mtext probably would not work, though I have not tried it offhand).
 Anyway, an example (code please, not just the picture), will clear up
 all these questions and we can offer a solution tailored to what you
 are doing.

 Cheers,

 Josh

 On Sun, Sep 18, 2011 at 1:18 PM, Amelia McNamara
 amelia.mcnam...@stat.ucla.edu wrote:
 I am trying to add a copyright disclaimer outside the plot borders of
 some images I have created. I can use mtext() to add the written
 portion, but I would like to have the Creative Commons license image
 (http://en.wikipedia.org/wiki/File:Cc.logo.circle.svg) before the
 text. I've found that I can plot a .png image inside the plot
 boundaries using rasterImage() but I can't figure out how to do it
 outside the boundaries.

 Any help would be great. If you know unicode or Adobe Symbol encoding
 for the CC logo, that might work too.

 ~Amelia McNamara
 Statistics PhD student, UCLA

 __
 R-help@r-project.org mailing list
 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.




 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, ATS Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/


__
R-help@r-project.org mailing list
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.


[R] Reduce the space under legend title

2011-08-11 Thread Amelia McNamara
I would like to know if there is a way to reduce the space between the
legend title and the first line of the legend, without reducing all
the vertical space using y.intersp. Because of lack of space, I would
like to differentiate my title by bolding it, and reduce the vertical
space under the title to the space typically used between categories
in a legend.

plot(c(1.1, 2.3, 4.6), c(2.0, 1.6, 3.2), pch=c(1,2,3))
legend(x=bottomright, legend=c(Category 1, Category 2, Category
3), title=expression(bold(Fairly long title)), pch=c(1,2,3),
bty=o)

~Amelia McNamara
Statistics PhD student, UCLA

__
R-help@r-project.org mailing list
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.


Re: [R] Creating png of layered legend

2011-07-26 Thread Amelia McNamara
Making the second layer of legend have full transparency seems to have fixed
the issue. My first layer has to have a white background because I have a
colored grid behind (sorry that didn't make it into my toy example).

I did try to use type=Xlib, but I get the error libpng warning:
Application built with libpng-1.2.26 but running with 1.5.2

My sessionInfo() is
R version 2.13.1 RC (2011-07-04 r56273)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

Thanks for your help, I never would have realized I needed to use a
transparent background.



On Tue, Jul 26, 2011 at 2:22 AM, Barry Rowlingson 
b.rowling...@lancaster.ac.uk wrote:

 On Tue, Jul 26, 2011 at 12:23 AM, Amelia McNamara
 amelia.mcnam...@stat.ucla.edu wrote:
  I am trying to create a plot that has multiple plot characters for
  each point (e.g. a point within a triangle, a triangle within a
  square, etc). The workaround I have found to do this is by plotting
  twice, as in this example:
 
  x - c(1.1, 2.3, 4.6)
  y - c(2.0, 1.6, 3.2)
  plot(x, y)
  points(x,y, pch=20, col=red, cex=0.5)
 
  This works, but perhaps there is a better way to do it in one step? My
  main problem comes when I want to make a legend. The workaround I have
  here is to again plot twice, as in
 
  legend(x=bottomright, legend=c(Category 1), text.col=white,
  title=Fairly long title, title.col=white, col=c(red),pch=20,
  pt.cex=0.5, bty=o, bg=white)
  legend(x=bottomright, legend=c(Category 1), title=Fairly long
  title, pch=1, bty=o)
 
  which produces the correct image in my Quartz window. I have to
  include the title and legend text in both versions, plotting the first
  one in white to avoid the text getting overplotted while still
  creating a legend border of the appropriate size.
 
  However, when I try to save this as a png, only the most recently
  plotted legend is captured. Saving as a pdf works, but the deliverable
  for this project is a png file and I would like to be able to produce
  them directly from R. Is there a way for me to capture both legends in
  a png? Or is there a better way for me to plot multiple symbols for a
  single point?

  Have you tried specifying the background colour as a transparent colour?

  try bg=#FF00 - the first hex doublet is full transparency, the
 next three doublets can be anything - in both.

  Note that your example looks fine for me as you gave it - I suspect
 the MacOS quartz PNG driver is doing something different to the Xlib
 driver. Can you use type=Xlib on your png() function call? What's
 your R version? And sessionInfo() output?

 Barry


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] Creating png of layered legend

2011-07-25 Thread Amelia McNamara
I am trying to create a plot that has multiple plot characters for
each point (e.g. a point within a triangle, a triangle within a
square, etc). The workaround I have found to do this is by plotting
twice, as in this example:

x - c(1.1, 2.3, 4.6)
y - c(2.0, 1.6, 3.2)
plot(x, y)
points(x,y, pch=20, col=red, cex=0.5)

This works, but perhaps there is a better way to do it in one step? My
main problem comes when I want to make a legend. The workaround I have
here is to again plot twice, as in

legend(x=bottomright, legend=c(Category 1), text.col=white,
title=Fairly long title, title.col=white, col=c(red),pch=20,
pt.cex=0.5, bty=o, bg=white)
legend(x=bottomright, legend=c(Category 1), title=Fairly long
title, pch=1, bty=o)

which produces the correct image in my Quartz window. I have to
include the title and legend text in both versions, plotting the first
one in white to avoid the text getting overplotted while still
creating a legend border of the appropriate size.

However, when I try to save this as a png, only the most recently
plotted legend is captured. Saving as a pdf works, but the deliverable
for this project is a png file and I would like to be able to produce
them directly from R. Is there a way for me to capture both legends in
a png? Or is there a better way for me to plot multiple symbols for a
single point?

Amelia McNamara

__
R-help@r-project.org mailing list
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.