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

Custom breaks not handled correctly when plotting #702

Closed
s-kganz opened this issue Aug 18, 2023 · 1 comment
Closed

Custom breaks not handled correctly when plotting #702

s-kganz opened this issue Aug 18, 2023 · 1 comment
Assignees
Labels
Enhancement Not actually a bug but a possible improvement

Comments

@s-kganz
Copy link

s-kganz commented Aug 18, 2023

Hello,

The documentation for lidR::plot says that the breaks argument can be

either a numeric vector with the actual breaks, or a name of a method accepted by the style argument of classIntervals

But when I try to supply my own breaks, an error is returned. To reproduce:

library(lidR)

LASfile <- system.file("extdata", "MixedConifer.laz", package="lidR")
las <- readLAS(LASfile)

plot(las, axis=TRUE, legend=TRUE, breaks=seq(0, 40, by=2))
#> Error in classInt::classIntervals(colorattr, min(nbreaks, nunique), breaks) : 
#>  0 unknown

Looking at the relevant function in classInt, it seems that one can specify the style as "fixed" and then pass the breaks as a separate argument:

mybreaks <- seq(0, 40, by=2)
classInt::classIntervals(las$Z, length(mybreaks), style="fixed", fixedBreaks=mybreaks)
#> style: fixed
#>  [0,2)   [2,4)   [4,6)   [6,8)  [8,10) [10,12) [12,14) [14,16) [16,18) [18,20) [20,22) [22,24) 
#>   9446     633     769    1087    1570    2164    3025    4052    4104    3847    3482    2098 
#> [24,26) [26,28) [28,30) [30,32) [32,34) [34,36) [36,38) [38,40] 
#>   1004     265      70      39       2       0       0       0 

Unless I'm missing something, this should be fixable with a small change in plot.

@Jean-Romain Jean-Romain self-assigned this Aug 21, 2023
@Jean-Romain Jean-Romain added the Enhancement Not actually a bug but a possible improvement label Aug 21, 2023
@Jean-Romain
Copy link
Collaborator

Fixed, thank you for reporting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not actually a bug but a possible improvement
Projects
None yet
Development

No branches or pull requests

2 participants