[Rd] format scientific + plotmath potential bug
I have run into a potential bug somewhere between format (specifically scientific notation) and plotmath that results in displaying: $1e+01^{2e+00}$ instead of $10^2$ Reproduce by: plot.new() a=format(10, scientific=TRUE) mtext(expression(10^2), line=1) # looks like $1e+01^{2e+00}$ 10 # this fixes the problem on the next line mtext(expression(10^2), line=2) # looks like $10^2$ I can narrow the trigger somewhat further by replacing the "a=..." line with: a=.Internal(format(10, FALSE, NULL, 0L, NULL, 3L, TRUE, TRUE)) Tracing this call into the C started giving me a headache, so I'm hoping that one of the R core gurus can confirm & file a bug report if necessary. I ran into this on Ubuntu / Lucid using R version 2.10.1 (2009-12-14). I confirmed it still exists in R 2.12.1 (2010-12-16) on a fresh install of Ubuntu / Maverick. Thanks, Philip __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] axis, title & padj
Hi, I often use par(mex = 0.5) as an easy way to shrink space used for margins. However, I recently noticed that this leads to an asymmetry in the positioning of the x vs. y axis labels and xlab / ylab -- the x-axis labels are pushed into the tic-marks, while the y-axis labels look fine. A more extreme example: dev.new() par(mex=.1, mar=c(10,10,10,10)) plot(1:10) Tracking this down in the code, this effect appears to be arising from: 1) GMtext in graphics.c adjusts the margin line coordinate using dev->yLineBias. After commenting out these adjustments, the x-axis text is clearly shifted up (i.e. the bottom of the text is aligned at the specified margin line) while the y-axis text is shifted left (i.e. the bottom of the text is still aligned with the specified margin line). 2) This observation lead me to realize that do_axis and do_title in plot.c assume padj=0 most of the time (there are exceptions depending on par()$las). I'm no expert in the R code base, but the yLineBias adjustments appears like they might have been intended to restore symmetry -- but it only works for mex=1. Is there a reason why, instead of yLineBias, we can't either: 1) center axis and title text by default (i.e. padj=0.5) -or- 2) align side=1,3 with padj=1; side=2,4 with padj=0 ? Solution 1 is trivial to implement, but this would shift positioning slightly relative to the current code (even for mex=1). Solution 2 is slightly trickier because we have to pay attention to side and las values, but would not change the output for mex=1. I implemented drafts of both solutions, which work at least superficially. Two questions: -Am I missing a larger purpose to yLineBias? -Thoughts about which solution is better / can I contribute a patch to fix this? Regards, Philip __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] x11 icon and class
The X11 device driver does not provide the X window manager with an icon (_NET_WM_ICON) or, under some circumstances, with a class (WM_CLASS). This hinders usability under the new stable version of Ubuntu, which has a (new) user interface centered around icons. I am not sure if this was a conscious choice by r-core or simply a low priority. In case of the latter, I attach a patch against R-devel (as of 6 June) that specifies: 1) _NET_WM_ICON as a slightly tweaked version of Rlogo-5.png (48x48 pixels, circle filled-in with white to be legible; ARGB data hardcoded as a constant array in a new file "rlogo_icon.h"). 2) WM_CLASS (for reasons unclear to me, previously WM_CLASS was only set #ifndef USE_Xt) l As Ubuntu is the single most popular linux distribution, perhaps others will find this patch useful. I have tested on both 32- and 64-bit versions of linux. Regards, Philip diff -Naur R-devel/src/modules/X11/devX11.c R-devel-patched/src/modules/X11/devX11.c --- R-devel/src/modules/X11/devX11.c 2012-05-28 20:53:33.0 -0400 +++ R-devel-patched/src/modules/X11/devX11.c 2012-06-07 14:48:40.359041743 -0400 @@ -70,6 +70,7 @@ typedef int (*X11IOhandler)(Display *); #include "devX11.h" +#include "rlogo_icon.h" /* hard-coded ARGB icon */ #include @@ -1580,8 +1581,9 @@ XStoreName(display, xd->window, xd->title); -#ifndef USE_Xt /* For those too idle to make use of Xt (PR#14588) */ +/* Not sure reason for above comment -- even with Xt, WM_CLASS + is not set on xd->window */ XClassHint *chint; chint = XAllocClassHint(); if (chint) { @@ -1590,7 +1592,13 @@ XSetClassHint(display, xd->window, chint); XFree(chint); } -#endif + +/* set window icon -- hardcoded into rlogo_icon.h */ +XChangeProperty(display, xd->window, +XInternAtom(display, "_NET_WM_ICON", False), +XInternAtom(display, "CARDINAL", False), 32, +PropModeReplace, +(const unsigned char*) rlogo_icon, 2 + 48*48); /* set up protocols so that window manager sends */ /* me an event when user "destroys" window */ diff -Naur R-devel/src/modules/X11/rlogo_icon.h R-devel-patched/src/mod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x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1868983,0x27e837a,0x6959595,0x2a888b85,0x5881857f,0x7d7f827b,0x9b7e827a,0xb17c8078,0xc07c7f78,0xc97c8179,0xca797e76,0xc3777c73,0xb4777b74,0x9d747971,0x8074786f,0x5b757870,0x2e797d75,0x77e847e,0x164685f,0x16b7168,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x38a8d88,0x68b8f89,0x288b8e89,0x71868983,0xba848881,0xf6838780,0xff838780,0xff838780,0xff848881,0xff848881,0xff848881,0xff848881,0xff858982,0xff81857e,0xff80847d,0xff7f837b,0xff7c8079,0xff787e76,0xff747a71,0xff71766d,0xf86f736b,0xbf6d7269,0x766c7169,0x2c70726c,0x7656a62,0x3666b63,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x58a8e87,0x1a8d918b,0x608a8f88,0xc9888c86,0xff878c85,0xff898d87,0xff8b8f89,0xff8c9089,0xfe8d918b,0xfe8f938d,0xff90948e,0xff91958e,0xff91968f,0xff91968f,0xff939891,0xff8f948d,0xff8f938c,0xff8d918b,0xff8a8f88,0xff878c85,0xfe858983,0xfe82867f,0xff7d8179,0xff777c73,0xff70756c,0xff6a6f66,0xcf676c63,0x65666c63,0x1d656a61,0x55f655b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x290978c,0x208e918b,0x728c9089,0xe48a8f88,0xff8c918a,0xff90948d,0xff91958e,0xfe929690,0xff91958e,0
Re: [Rd] x11 icon and class
On 06/12/2012 03:50 PM, Davor Cubranic wrote: On 2012-06-07, at 12:05 PM, Philip Johnson wrote: The X11 device driver does not provide the X window manager with an icon (_NET_WM_ICON) or, under some circumstances, with a class (WM_CLASS). This hinders usability under the new stable version of Ubuntu, which has a (new) user interface centered around icons. [...] 2) WM_CLASS (for reasons unclear to me, previously WM_CLASS was only set #ifndef USE_Xt) A few comments in the bug database give a hint why this is conditional (http://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14588): (1) "resources are only handled in the Xt case" (comment #1) (2) "Still no explanation as to why Xt is not used, and this should be conditional on that case." (comment #3) True, however, as far as I could tell, these comments do not apply to the current code for the following reasons: (1) ./configure --with-x requires that Xt be present (2) devX11.c includes a line "#define USE_Xt 1" -- implying that Xt is *always* used if compiling for X11 (3) Xt* functions are only used in a single small block in the code, and no windows are created in that code -- and thus no X resources are EVER set. I *think* that the only purpose of this code is to test whether the window manager allows the user to specify window position and size. But these fields in XSizeHints are noted in the current man pages as "obsolete and left solely for compatibility reasons". (4) deleting all Xt code makes no discernable difference in the device driver behaviour on my (admittedly modern) linux distribution. Now that GUI libraries typically don't rely on Xt any more (e.g., Gtk), but WM_CLASS (and possibly other resources) are still used by window managers, it arguably makes sense for the X11 driver to always set this property. This is my argument in a nutshell. I understand there is a general reluctance to delete old code because it might still be used on an old system somewhere, but I think my proposed change would only be adding functionality, not removing it. After I sent the patch, I discovered that the integration with the new Ubuntu interface works even better if WM_CLASS matches the name of the executable -- i.e. if the class were "R" rather than "R_x11". I don't want to spam this list, but I am happy to send a revised patch if asked. Regards, Philip __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R 2.15.2 still missing two files useful with the X11 icon patch
Glad to see this as well. Two notes on Dirk's comments: 1) As Dirk wrote, the changes in 2.15.2 apply to almost any X11 system (although, as the NEWS says, this change is particularly crucial with Ubuntu's new Unity interface). 2) The additional two files mentioned by Dirk are only useful on systems complying with the freedesktop.org standards (i.e., at least gnome and kde). With Unity, these files result in a crisper icon in the Unity launcher. To summarize: the change in R 2.15.2 helps any X11 system. The additional two files not yet in mainline R help only freedesktop.org-compliant systems -- although I can't imagine how they would hurt any other system. Thanks for incorporating at least the first patch into main line development! Regards, Philip On 10/26/2012 10:07 AM, Dirk Eddelbuettel wrote: Congrats on getting 2.15.2 out on schedule. Debian builds have been uploaded. It is my understanding that Phil's patch for the X11 logo -- so promimently featured as the first item in the NEWS file for the release -- offers more when two extra files are supplied. I have supplied these for the Debian test release, for our 2.15.1-* releases and again now. We install these files as /usr/share/icons/hicolor/48x48/apps/rlogo_icon.png /usr/share/applications/R.desktop and I would urge R Core to do the same so that users of other binaries get the same benefit. I have in fact mailed twice already before about this. As I understand, with the 'desktop' files and the png it references, menus showing R as an entry get more meta info, and a crisper (png) logo. Now, the NEWS file entry is also half-incorrect. The benefit of the patch is visible in Ubuntu, nomatter which desktop env you use, but not limited to it. Even under Windows 7, the taskbar now supplies the R icon when the patched Debian / Ubuntu build is used --- but not with an rpm build of 2.15.1 where the generic x11 icon is shown. Having R windows visually identified as such is very useful, no matter the Linux or X11 flavour. And that is what Phil's patch does this: adds the feature no matter the X11 GUI or desktop environment. Dirk __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel