# breaks on original or transformed data#373

Closed
opened this Issue · 5 comments

### 3 participants

Collaborator

Automatic pretty break is convenient in most cases, but as I mentioned above, at the moment it is somewhat confusion in scales with transformation w.r.t the data space.

Users may want a pretty breaks on the original data space or on the transformed data space.
This choice should be done explicitly.

I would propose one extra option, i.e., users can choose the pretty breaks on the original or transformed data.
Then, the `continuous_scale` will be:

`continuous_scale(..., breaking = c("original", "transformed"))`

name should be considered.

If original, then it has pretty breaks on the original data range.
If transformed, then it has pretty breaks on the transformed data range.

OR, maybe, `breaks` can accept a character specifying the data space.
I like the former style though.

Also, major and minor breaks may as well have their own basis.
There are many examples of such plot even in the wikipedia:
http://en.wikipedia.org/wiki/Logarithmic_scale

But the example in the wikipedia is more special...

Owner

Isn't this what `trans_breaks` does? The default in ggplot2 is to space major breaks evenly in the transformed space, and the minor breaks evenly in the data space.

Collaborator

OK, I see.
Here is the example:

```p <- qplot(seq(1, 1e4, len = 10), seq(1, 1e5, len = 10)) + geom_line()
# on original data space
p + scale_x_log10()
# on transformed data space
p + scale_x_log10(breaks = trans_breaks(log10_trans()\$trans, log10_trans()\$inv))```

is this what you mean?

Maybe this is somewhat complicated.
As the scale_x_log10 already knows the trans/inv, so it should be written like this:

`p + scale_x_log10(breaks = trans_breaks())`
added a commit to kohske/ggplot2 that referenced this issue
 kohske `scale breaks: automatic transformed scale (#373)` `2848e39`
Collaborator

Here is an experimental implementation above.

```p <- qplot(seq(1, 1e4, len = 10), seq(1, 1e5, len = 10)) + geom_line()
p + scale_x_log10()
p + scale_x_log10(breaks = auto_break_trans())
# identical to
# p + scale_x_log10(breaks = trans_breaks(log10_trans()\$trans, log10_trans()\$inv))```
referenced this issue
Merged