[R] ggplot2 to create a "square" plot

baptiste auguie baptiste.auguie at googlemail.com
Thu Sep 1 23:02:46 CEST 2011


Hi,

Are you after this?

last_plot() + opts(aspect.ratio=1)

Also, see https://github.com/hadley/ggplot2/wiki/Themes for some
settings re: plot margins.

HTH,

baptiste

On 1 September 2011 05:18, Alaios <alaios at yahoo.com> wrote:
> Dear all,
> I am using ggplot with geom_tile to print as an image a matrix  I have. My matrix is a squared one of 512*512 cells.
>
> The code that does that is written below
>
>
>> print(v + geom_tile(aes(fill=dB))+ opts(axis.text.x=theme_text(size=20),axis.text.y=theme_text(size=20), axis.title.x=theme_text(size=25) , axis.title.y=theme_text(size=25), legend.title=theme_text(size=25,hjust=-0.4) , legend.text=theme_text(size=20)) + scale_x_continuous('km')  + scale_y_continuous('km')    )
>
>
>
> as you can see from the picture below
>
> http://imageshack.us/photo/my-images/171/backupf.jpg/
>
> this squared matrix is printed a bit squeezed with the height being bigger than the width. Would be possible somehow to print that plot by keeping the square-look of the matrix in the plot? Of course the other elements like axis and legend will make the over all plot to not be square but I do not care as the blue and red region forms a square.
>
> I would like to thank you in advance for your help
> B.R
> Alex
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>
>



More information about the R-help mailing list