I'm using the image.plot() function (fields package), but I want to enlarge the characters of the legend (as they are too small to be read in a combined figure), but there is no way I can find a command to do this. I can enlarge the legend bar (with legend.witdh), axis character size (cex.axis) or the total legend size (legend.shrink), but not the character size of the legend characters itself (and only that). Is it possible to do it in one or another way? Regards, Dieter -- View this message in context: http://r.789695.n4.nabble.com/change-legend-character-size-in-image-plot-tp3657423p3657423.html Sent from the R help mailing list archive at Nabble.com.
On Jul 10, 2011, at 6:16 AM, dmeire wrote:> I'm using the image.plot() function (fields package), but I want to > enlarge > the characters of the legend (as they are too small to be read in a > combined > figure), but there is no way I can find a command to do this. I can > enlarge > the legend bar (with legend.witdh), axis character size (cex.axis) > or the > total legend size (legend.shrink), but not the character size of the > legend > characters itself (and only that). Is it possible to do it in one or > another > way?Looking at the code, it appears to me that the legend text is written with mtext() and that there was no provision made for passing a cex parameter to the calls. This appears to be the code that would need to be considered and modified: #------------ if (!is.null(legend.lab)) { legend.args <- list(text = legend.lab, side = ifelse(horizontal, 1, 4), line = legend.mar - 2) } if (!is.null(legend.args)) { do.call(mtext, legend.args) #--------------- See if creating a modified version of image.plot with an added parameter to control cex.legend give you something more useful. -- David Winsemius, MD West Hartford, CT
On 2011-07-10 03:16, dmeire wrote:> I'm using the image.plot() function (fields package), but I want to enlarge > the characters of the legend (as they are too small to be read in a combined > figure), but there is no way I can find a command to do this. I can enlarge > the legend bar (with legend.witdh), axis character size (cex.axis) or the > total legend size (legend.shrink), but not the character size of the legend > characters itself (and only that). Is it possible to do it in one or another > way?What do you mean by "legend characters"? The help page has an example that shows how to modify a legend label ('title' might be a better term) using a legend.args list. If you mean the axis labels on the legend, then use an axis.args list with appropriate cex.axis setting). E.g. image.plot(x, y, z, axis.args = list(cex.axis = 2)) If this is not what you have in mind, then you should provide a reproducible example that illustrates the problem. Peter Ehlers> > Regards, > Dieter > > -- > View this message in context: http://r.789695.n4.nabble.com/change-legend-character-size-in-image-plot-tp3657423p3657423.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
Dr. Thomas W. MacFarland
2011-Jul-11 12:40 UTC
[R] change legend character size in image.plot
Hi Dieter: See if this approach (below) to adjusting legend contents works for you. Note how family and font apply only to the legend. Best wishes. Tom ################################################# # Histogram of the Summary Object Variable with # # an Added fivenum() Output in a Legend # ################################################# hist(AgChem.table$Larvae, main="Histogram of Larvae Counts, With fivenum() Output: Minimum, 1Q, Median, 3Q, Maximum", xlab="Larvae Counts (Limit = 0 to 180)", xlim=c(120,160), # Scale adjusted for presentation. ylim=c(0,50), # Scale adjusted for presentation. font.lab=2, font.axis=2, border="blue", col="red", nclass=50, freq=TRUE, prob=FALSE) axis(side=1, line=-0.1, at=fivenum(AgChem.table$Larvae)[1:5], lwd=1, tick=TRUE, font=2, labels=c("Minimum", "1Q","Median","3Q", "Maximum"), cex.axis=1.05, col.axis="black", padj=-2.9) savefamily <- par(family="mono") # Courier font savefont <- par(font=2) # Bold legend("topright", legend = c( "Tukey's five number summary", "==================================", "> fivenum(AgChem.table$Larvae) ", "[1] 122.0 135.5 138.0 140.0 156.0 ", "----------------------------------", "122.0 Minimum ", "135.5 Lower-Hinge (1Q) ", "138.0 Median ", "140.0 Upper-Hinge (3Q) ", "156.0 Maximum ", "----------------------------------"), ncol=1, locator(1), xjust=1, text.col="black", cex=1.15, inset=0.025, bty="n") par(savefamily) par(savefont) # The legend for this figure is rather large. # It was set to a Courier-type mono-spaced font # to have all fivenum() function values and # character values line up properly. Date: Sun, 10 Jul 2011 03:16:00 -0700 (PDT) From: dmeire <dieter.meire@ugent.be> To: r-help@r-project.org Subject: [R] change legend character size in image.plot Message-ID: <1310292960960-3657423.post@n4.nabble.com> Content-Type: text/plain; charset=us-ascii I'm using the image.plot() function (fields package), but I want to enlarge the characters of the legend (as they are too small to be read in a combined figure), but there is no way I can find a command to do this. I can enlarge the legend bar (with legend.witdh), axis character size (cex.axis) or the total legend size (legend.shrink), but not the character size of the legend characters itself (and only that). Is it possible to do it in one or another way? Regards, Dieter -- View this message in context: http://r.789695.n4.nabble.com/change-legend-character-size-in-image-plot-tp3 657423p3657423.html Sent from the R help mailing list archive at Nabble.com. Thomas W. MacFarland, Ed.D. Senior Research Associate; Institutional Effectiveness and Associate Professor Nova Southeastern University Voice 954-262-5395 Fax 954-262-3970 <mailto:tommac@nsu.nova.edu> tommac@nsu.nova.edu [[alternative HTML version deleted]]