Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor_breaks function ignored #403

Closed
baptiste opened this issue Feb 12, 2012 · 14 comments
Closed

minor_breaks function ignored #403

baptiste opened this issue Feb 12, 2012 · 14 comments
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@baptiste
Copy link
Contributor

## setting numeric values for minor_breaks works:

qplot(10^(1:6), 10^(1:6)) + scale_x_log10(breaks = 10^(1:6),
  minor_breaks = log(c(sapply(10^(1:6), function(x) seq(0, x, x/10))), 10))) 

## but a function is ignored:

qplot(10^(1:6), 10^(1:6)) + scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x, n=6) ,
   minor_breaks = trans_breaks("log10", function(x) 10^x, n=60) )

the minor breaks disappear entirely.

@kohske
Copy link
Collaborator

kohske commented Feb 12, 2012

Actually that is not ignored, but simply out of range.

qplot(10^(1:6), 10^(1:6)) + scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x, n=6) ,
   minor_breaks = trans_breaks("log10", function(x) log(10^x, 10), n=60) )

will work.

The breaks internally transform the data, while the minor breaks do not.
I know it's confusing.

@baptiste
Copy link
Contributor Author

oh, I see, thanks. I think it would be much less confusing to have the same behavior as major breaks. Also, the example you submitted

qplot(10^(1:6), 10^(1:6)) + scale_x_log10(breaks = 10^(1:6),
minor_breaks = log(c(sapply(10^(1:6), function(x) seq(0, x, x/10))), 10))

would be quite useful in the documentation for scale_x_log10.

@hadley
Copy link
Member

hadley commented Feb 13, 2012

We probably need a little documentation for scale_breaks_minor describing exactly what it does.

@kohske
Copy link
Collaborator

kohske commented Feb 26, 2012

We probably need a little documentation for scale_breaks_minor describing exactly what it does.

Who is going to?

@hadley
Copy link
Member

hadley commented Feb 27, 2012

I'll do it - either today or tomorrow. (Note to self: also make sure to document minor_breaks arguments to date scales)

@hadley
Copy link
Member

hadley commented Feb 27, 2012

Hmmm, this is more complicated than I thought. Ideally, we should be able to wrap the default behaviour (n evenly spaced minor breaks between each major break) into a standard minor breaks function - but currently it needs both the major breaks and the limits. This may suggest that the minor breaks function should get both those arguments - but then all other minor breaks functions will need to be rewritten (e.g. for date and date time).

We also need someway to easily control the number of minor breaks between major breaks.

@hadley
Copy link
Member

hadley commented Feb 27, 2012

See exploration in minor_breaks branch: https://github.com/hadley/ggplot2/compare/minor_breaks

@kohske
Copy link
Collaborator

kohske commented Feb 27, 2012

We also need someway to easily control the number of minor breaks between major breaks.

ggplot2 may have its own number + unit representation (at least internally).

e.g.,

minor_breaks = c(0, 1, 2) # raw numeric
minor_breaks = ggunit(1, "count") # number of minor breaks between major breaks
minor_breaks = ggunit(-1, "level") # in the case of date/datetime, if major breaks = month, minor = week.

I imagine this function would be useful in many places.

@kohske
Copy link
Collaborator

kohske commented Feb 27, 2012

of course ggunit is a simple function like this:

ggunit <- function(value, unit = "I", ...) 
  structure(value, class = "ggunit", unit = unit, ...)

@kohske
Copy link
Collaborator

kohske commented Feb 27, 2012

ggunit is available also for data space identifier. like:

breaks = ggunit(c(1:10), "transformed")
breaks = ggunit(c(1:10), "original")

the name ggunit should be reconsidered, though.

@hadley
Copy link
Member

hadley commented Feb 27, 2012

I think this is big enough that I'm going to put it off until 0.9.1

@hadley
Copy link
Member

hadley commented Apr 11, 2012

And now until 0.9.2

@chmullig
Copy link

It appears this is still in 0.9.3.

@hadley
Copy link
Member

hadley commented Feb 24, 2014

This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette.

@hadley hadley closed this as completed Feb 24, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants