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

collapse layer selector in mode "view" & scale trans functions (pseudo_log with sigma) #847

Open
xtimbeau opened this issue Mar 16, 2024 · 6 comments

Comments

@xtimbeau
Copy link

Hi, thanks for the package and the new v4 option, love the scale stuff (but you should add trans for neg/pos range like pseudo log).

Is there a way to collapse the layer selector in interactive mode (tmap-mode("view"). It stays open and occupy a lot of space on a standard map.

@mtennekes
Copy link
Member

Hi @xtimbeau thanks for letting me know. This is a view-only option which we still have to migrate. Not a lot of work though :-)

Besides that, I am curious about your suggestion related to the scale. Can you give me an example?

@xtimbeau
Copy link
Author

hi @mtennekes, you can have a look at the scales package (https://scales.r-lib.org/reference/log_trans.html). Such transformation is very useful for color scales when the range of colors is negative to positive but when a linear scale gives too much room to high absolute value. Using that transform (and the cut parameter associated) allows to improve contrast.

mtennekes added a commit that referenced this issue Mar 19, 2024
@mtennekes
Copy link
Member

Ok, I borrowed some code from scales::pseudo_log_trans, and implemented a new trans, called "pseudo_log".

Please check if it makes sense @xtimbeau :

World$HPI2 = World$HPI - 30
tm_shape(World) +
	tm_polygons("HPI2", fill.scale = tm_scale_continuous())
tm_shape(World) +
	tm_polygons("HPI2", fill.scale = tm_scale_continuous(trans = "pseudo_log"))

The functions from scales has two parameters, sigma and base. Are both useful?

Could you provide a data example for this scale would be useful?

@xtimbeau
Copy link
Author

@mtennekes great ! I'll test it and try to factor a nice example.

@xtimbeau
Copy link
Author

@mtennekes sigma is quite useful as it sets the cut for when the log is smoothed to a linear function. Pseudo log looks like a log above a few signa (or below a few -sigma) but is linear between -sigma and sigma. Base is also relevant because of that non log linearity.

@olivroy olivroy added the view View mode issues label Apr 11, 2024
@mtennekes mtennekes removed the view View mode issues label May 1, 2024
@mtennekes mtennekes changed the title collapse layer selector in mode "view" collapse layer selector in mode "view" & scale trans functions (pseudo_log with sigma) May 1, 2024
@mtennekes
Copy link
Member

Collapse has already been set to TRUE by default (forgot to mention earlier).

I've implemented tm_scale_continuous_pseudo_log, with sigma and base. Indeed very handy @xtimbeau this sigma parameter!

Also added tm_scale_continuous_log10, tm_scale_continuous_log2, and tm_scale_continuous_log with base. Please check. The only difference between log, log2, log10, is that with a base other than exp(1), the labels will be formatted as base^x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants