<br><br><div class="gmail_quote">On Wed, Sep 1, 2010 at 6:54 AM, Yihui Xie <span dir="ltr"><<a href="mailto:xie@yihui.name">xie@yihui.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Thanks! That was my guess, but it does not seem to work, e.g.:<br>
<br></blockquote><div><br>I would suggest turning off caching, i.e., pass cache=FALSE to qlayer, at least for the two axes. The issue, I think, is that Qt will only allocate a buffer large enough for the layer. You're then drawing outside of the cache, and it never makes it to the screen. I might make clip and cache both default to FALSE. Caching usually only makes sense when there is a dynamic overlay on the layer. This is usually not the case for axes. <br>
<br>Michael<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
# all layers with clip=FALSE but still get clipped<br>
library(qtpaint)<br>
scene = qscene()<br>
figLayer = qlayer(scene, clip = FALSE)<br>
titlePainter = function(item, painter) {<br>
qdrawText(painter, paste(rep("The Useless Title", 5), collapse = " - "),<br>
300, 10, "center", "center")<br>
<div class="im">}<br>
yAxisPainter = function(item, painter) {<br>
qdrawText(painter, as.character(pretty(1:400)), 37.5, pretty(1:400))<br>
}<br>
plotPainter = function(item, painter) {<br>
qdrawPoint(painter, runif(1000, 0, 600), runif(1000, 0, 400))<br>
qdrawRect(painter, 1, 1, 600 - 1, 400 - 1)<br>
}<br>
xAxisPainter = function(item, painter) {<br>
qdrawText(painter, as.character(pretty(1:600)), pretty(1:600),<br>
37.5)<br>
}<br>
mouseLocator = function(item, event) {<br>
print(as.numeric(event$pos()))<br>
}<br>
titleLayer = qlayer(figLayer, titlePainter, mousePressFun = mouseLocator,<br>
</div> limits = qrect(0, 0, 600, 20), clip = FALSE, row = 0, col = 1)<br>
<div class="im">yaxis = qlayer(figLayer, yAxisPainter, mousePressFun = mouseLocator,<br>
</div> limits = qrect(0, 0, 75, 400), clip = FALSE, row = 1, col = 0)<br>
<div class="im">plotLayer = qlayer(figLayer, plotPainter, mousePressFun = mouseLocator,<br>
</div> limits = qrect(0, 0, 600, 400), clip = FALSE, row = 1, col = 1)<br>
<div class="im">xaxis = qlayer(figLayer, xAxisPainter, mousePressFun = mouseLocator,<br>
</div> limits = qrect(0, 0, 600, 75), clip = FALSE, row = 2, col = 1)<br>
<br>
layout = figLayer$gridLayout()<br>
<div class="im"><br>
layout$setRowStretchFactor(0, 1)<br>
layout$setRowStretchFactor(1, 5)<br>
layout$setRowStretchFactor(2, 1)<br>
layout$setColumnStretchFactor(0, 1)<br>
layout$setColumnStretchFactor(1, 5)<br>
<br>
print(view <- qplotView(scene = scene))<br>
<br>
<br>
</div><div class="im">Regards,<br>
Yihui<br>
--<br>
Yihui Xie <<a href="mailto:xieyihui@gmail.com">xieyihui@gmail.com</a>><br>
Phone: 515-294-6609 Web: <a href="http://yihui.name" target="_blank">http://yihui.name</a><br>
Department of Statistics, Iowa State University<br>
</div><div class="im">2215 Snedecor Hall, Ames, IA<br>
<br>
<br>
<br>
</div><div><div></div><div class="h5">On Wed, Sep 1, 2010 at 7:26 AM, Hadley Wickham <<a href="mailto:hadley@rice.edu">hadley@rice.edu</a>> wrote:<br>
> For the answer to your first question, turning clipping off for that layer.<br>
><br>
> Hadley<br>
><br>
> On Wednesday, September 1, 2010, Yihui Xie <<a href="mailto:xie@yihui.name">xie@yihui.name</a>> wrote:<br>
>> Hi all,<br>
>><br>
>> I'm wondering if there are any approaches to completely show the<br>
>> graphical elements on the boundaries under a layout containing several<br>
>> layers. This is like the functionality par(xpd=NA) in base R graphics.<br>
>> See the example below that the texts for the origin (0,0) on the axes<br>
>> are partially hidden.<br>
>><br>
>> My another problem is, I don't really understand the layout approach,<br>
>> although I've been reading the qtpaint vignette and digging the Nokia<br>
>> Qt documentations. Specifically, how should we define the coordinate<br>
>> system in each layer in a layout? (I experimented with mouse clicking<br>
>> to get locations but got even more confused) With a single layer, I<br>
>> can plot the data using its range to define the limits and everything<br>
>> is fine. Besides, does anyone have a working demo to draw a simplest<br>
>> plot with the layout approach? I struggled with<br>
>> set(Column|Row)(Maximum|Minimum|Preferred)(Width|Height) and<br>
>> set(Column|Row)StretchFactor, but they do not behave as we expect them<br>
>> to, e.g. the stretch factor being 0 will not restrict the height/width<br>
>> of a layer to be a fixed value -- they change as we resize the window.<br>
>><br>
>> Below is the R code:<br>
>><br>
>> # I need hints on how to split the root layer into several regions<br>
>> # and what are their coordinate systems<br>
>> library(qtpaint)<br>
>> scene = qscene()<br>
>> figLayer = qlayer(scene,limits=qrect(0,0,675,550))<br>
>> titlePainter = function(item, painter) {<br>
>> qdrawText(painter, 'The Useless Title', 300, 0,'center','bottom')<br>
>> tmp=as.matrix(titleLayer$boundingRect())<br>
>> qdrawRect(painter, tmp[1,1],tmp[1,2],tmp[2,1],tmp[2,2])<br>
>> }<br>
>> yAxisPainter = function(item, painter) {<br>
>> qdrawText(painter, as.character(pretty(1:400)), 37.5, pretty(1:400))<br>
>> }<br>
>> plotPainter = function(item, painter) {<br>
>> qdrawPoint(painter, runif(1000, 0, 600), runif(1000, 0, 400))<br>
>> qdrawRect(painter, 1, 1, 600-1, 400-1)<br>
>> }<br>
>> xAxisPainter = function(item, painter) {<br>
>> qdrawText(painter, as.character(pretty(1:600)), pretty(1:600), 37.5)<br>
>> }<br>
>> mouseLocator = function(item, event){<br>
>> print(as.numeric(event$pos()))<br>
>> }<br>
>> titleLayer = qlayer(figLayer, titlePainter,<br>
>> mousePressFun=mouseLocator, row=2,col=1)<br>
>> yaxis = qlayer(figLayer, yAxisPainter,mousePressFun=mouseLocator,row = 1,col=0)<br>
>> plotLayer = qlayer(figLayer, plotPainter,<br>
>> mousePressFun=mouseLocator,row = 1, col = 1)<br>
>> xaxis = qlayer(figLayer, xAxisPainter, mousePressFun=mouseLocator,row<br>
>> = 0, col = 1)<br>
>><br>
>> layout = figLayer$gridLayout()<br>
>><br>
>> layout$setRowMaximumHeight(0, 75)<br>
>> layout$setRowMinimumHeight(0, 60)<br>
>> # main plot region: 400x600<br>
>> layout$setRowPreferredHeight(1, 400)<br>
>> layout$setRowMaximumHeight(2, 75)<br>
>> layout$setRowMinimumHeight(2, 60)<br>
>><br>
>> layout$setColumnMaximumWidth(0, 75)<br>
>> layout$setColumnMinimumWidth(0, 60)<br>
>> layout$setColumnPreferredWidth(1, 600)<br>
>> layout$setRowStretchFactor(0, 0)<br>
>> layout$setRowStretchFactor(1, 1)<br>
>> layout$setRowStretchFactor(2, 0)<br>
>> layout$setColumnStretchFactor(0, 0)<br>
>> layout$setColumnStretchFactor(1, 1)<br>
>><br>
>> print(view<-qplotView(scene = scene))<br>
>><br>
>><br>
>> #################################################<br>
>><br>
>>> sessionInfo()<br>
>> R version 2.11.1 (2010-05-31)<br>
>> x86_64-pc-linux-gnu<br>
>><br>
>> locale:<br>
>> [1] en_US.utf8<br>
>><br>
>> attached base packages:<br>
>> [1] stats graphics grDevices utils datasets methods base<br>
>><br>
>> other attached packages:<br>
>> [1] qtpaint_0.7.9<br>
>><br>
>> loaded via a namespace (and not attached):<br>
>> [1] qtbase_0.8-4 tools_2.11.1<br>
>><br>
>><br>
>> Thanks a lot!<br>
>><br>
>> Regards,<br>
>> Yihui<br>
>> --<br>
>> Yihui Xie <<a href="mailto:xieyihui@gmail.com">xieyihui@gmail.com</a>><br>
>> Phone: 515-294-6609 Web: <a href="http://yihui.name" target="_blank">http://yihui.name</a><br>
>> Department of Statistics, Iowa State University<br>
>> 3211 Snedecor Hall, Ames, IA<br>
>> _______________________________________________<br>
>> Qtinterfaces-devel mailing list<br>
>> <a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
>> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
>><br>
><br>
> --<br>
> Assistant Professor / Dobelman Family Junior Chair<br>
> Department of Statistics / Rice University<br>
> <a href="http://had.co.nz/" target="_blank">http://had.co.nz/</a><br>
><br>
_______________________________________________<br>
Qtinterfaces-devel mailing list<br>
<a href="mailto:Qtinterfaces-devel@lists.r-forge.r-project.org">Qtinterfaces-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/qtinterfaces-devel</a><br>
</div></div></blockquote></div><br>