Changing plot scales

123 views
Skip to first unread message

snoo...@gmail.com

unread,
Oct 6, 2014, 8:58:36 PM10/6/14
to ded...@googlegroups.com
Hi,

I'm relatively new to Deducer, so this may be a silly question...

I'm using a Bubble plot for my data. I have data that I want to plot as Log2 on the X and Y axis. I've manged to do this fine, but I want to be able to use tick labels as 2^4, 2^3, 2^2, 2^1 etc as required. At the moment it defaults to the actual value. I haven't been able to figure out how to change the format. Can somebody point me in the right direction?

If I can't do this, how can I control the numbe of decimal places? In fact I'd like to know this for future reference.

One last question; how do I control font size for the tick labels and the axis labels in general?

Thanks,

Peter

Tom Hopper

unread,
Oct 8, 2014, 2:15:21 PM10/8/14
to ded...@googlegroups.com
Peter,

You'll need the scales package loaded. Add a "scale_y_continuous" component from the "Scales" tab, then change the "Labels" drop-down menu. Some of the options can be further tweaked via the gear symbol (e.g. controlling the number of decimal places when selecting "Scientific" labels).

If you want more control over the results, you'll have to create your own label function, and I think you'll then have to manually change the code produced by the Plot Builder; I don't know if it's possible to get Deducer to call a custom labelled. See, for example, http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/#tick-mark-label-text-formatters.

Regards,

Tom


--

---
You received this message because you are subscribed to the Google Groups "Deducer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deducer+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

snoo...@gmail.com

unread,
Oct 8, 2014, 4:59:25 PM10/8/14
to ded...@googlegroups.com
Hi Tom,

thanks for that, I did try "scientific", but the console was giving me the following error message:

Error in structure(list(call = match.call(), aesthetics = aesthetics,  :
  could not find function "scientific_format"

I wasn't sure if I'd failed to set something up properly, or something else was wrong. I'll take a look at the link and see if I can work it out.

Tom Hopper

unread,
Oct 8, 2014, 10:11:42 PM10/8/14
to ded...@googlegroups.com
Peter,

I had the same problem until I loaded the scales package from the JGR command line.

- Tom

Sent from my iPhone
--

snoo...@gmail.com

unread,
Oct 13, 2014, 5:20:24 PM10/13/14
to ded...@googlegroups.com
Brilliant, that did the trick...

thanks.


On Tuesday, October 7, 2014 11:58:36 AM UTC+11, snoo...@gmail.com wrote:

Bruce Miller

unread,
Oct 14, 2014, 9:45:50 PM10/14/14
to ded...@googlegroups.com
Related to plot "scales"

How does one control the size (width) of the histogram bars?

I played with the Options binwidth and width in plot builder and set
these from 0 to 20 and seemed to have no effect.


> ggplot() +
+ theme_bw() +
+ xlab(label = 'Species') +
+ ylab(label = 'Rank abundance') +
+ geom_bar(aes(y = Abundance.tr,x = Species),data=chileanBats,colour =
'#0000cc',fill = '#0000cc',size = 0.05) +
+ opts(title = 'High level of disturbance',axis.text.x = theme_text(size
= 11.0))

Tom Hopper

unread,
Oct 15, 2014, 4:03:49 PM10/15/14
to ded...@googlegroups.com
Bruce,

With what you're doing, you should be seeing a confusing error message in the JGR console whenever you try to plot that code. The upshot is that you need to set stat="identity" for geom_bar() (in the drop-down menu above the "mappings" tab) in order to treat your x variable as location of bins and y variable as the count/density/frequency within each bin.

df <- data.frame(x = c(0, 0.5, 1, 1.5, 2, 2.5), y = c(1, 2, 3, 4, 3, 2))
ggplot() +
geom_bar(aes(x = x,y = y),data=df,stat = 'identity')

Once you've done this, you cannot control bin width, because you've implicitly specified the bin widths with your x variable.

If you want to control bin width from within the ggplot2 call, you need your x variable to represent individual observations that can be summarized into counts within bins.

df2 <- data.frame(x = rnorm(100))
ggplot() +
geom_histogram(aes(y = ..count..,x = x),data=df2,binwidth = 0.5)

Here, I've explicitly included "y = ..count..", which is normally the default in geom_histogram() and not displayed in the call printed out by Deducer's "View call" command.

Regards,

Tom


--

--- You received this message because you are subscribed to the Google Groups "Deducer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deducer+unsubscribe@googlegroups.com.

Tom Hopper

unread,
Oct 15, 2014, 4:09:57 PM10/15/14
to ded...@googlegroups.com
Ian, perhaps Deducer should be loading scales automatically to prevent this sort of error?

Regards,

Tom


--

---
You received this message because you are subscribed to the Google Groups "Deducer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deducer+u...@googlegroups.com.

Ian Fellows

unread,
Oct 16, 2014, 1:51:59 PM10/16/14
to ded...@googlegroups.com
Yes, thanks for the report. ggplot2 used to load scales, but now it only imports it. I’ll update deducer to reflect this.

Best,
Ian

Bruce Miller

unread,
Oct 17, 2014, 7:55:52 AM10/17/14
to ded...@googlegroups.com
Hi all,

I need to transform values to log base 10, but the drop down for
transformation only provides natural log and log+1.

GGplot2 documentation suggests adding

scale_x_log10(...)
but I can not seem to have the correct context to use plot builder to
obtain that.

Bruce


Ian Fellows

unread,
Oct 17, 2014, 10:06:35 AM10/17/14
to ded...@googlegroups.com
Bruce,

Go to scales and select "X Continuous.” Then change Transform to “log10: log base 10”

Best,
Ian

Bruce Miller

unread,
Nov 10, 2014, 3:31:35 PM11/10/14
to ded...@googlegroups.com, ifellows@gmail.com >> Ian Fellows
Hi all,

I am working with a new grad student and wanted her to install Deducer
to work with R.

She has a new MAC but just indicated she could not install it.
"The new operating system (Yosemite) has problems with it"

She has a Windows emulator so I assume (not being a MAC person) that
this may work for R and Deducer?

Bruce

rudolf....@gmail.com

unread,
Nov 10, 2014, 5:59:37 PM11/10/14
to ded...@googlegroups.com

Bruce

Deducer works perfectly well on the Mac with Yosemite (10.10). No problems at all.
But before you can do anything with R or JGR, get your new Mac ready by downloading the required infrastructure to run the code.
There is a good description on cran for this.
The Mac requires Xcode plus programming tools and a compatible java, perhaps download XQuartz in addition (for some graphical output, deducer may not need this).
On a Mac upgraded to 10.10, one still has to re-install some of those components. Note, not all java versions are compatible with Yosemite. But if you just take the latest release your are fine.

Hope this helps.
Rudolf

Tom Hopper

unread,
Nov 10, 2014, 7:56:48 PM11/10/14
to ded...@googlegroups.com
R works fine with Yosemite if she follows the R-admin manual (http://cran.r-project.org/doc/manuals/r-release/R-admin.html#Yosemite). She'll want/need to install Apple's Java at http://support.apple.com/kb/DL1572

Regards,

Tom

Reply all
Reply to author
Forward
0 new messages