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

Request: Log-scales should use original units #464

Open
ParadaCarleton opened this issue Jun 22, 2023 · 3 comments
Open

Request: Log-scales should use original units #464

ParadaCarleton opened this issue Jun 22, 2023 · 3 comments

Comments

@ParadaCarleton
Copy link

AoG offers log scales, but they seem to behave awkwardly. Asking for log scales on a density currently results in replacing

However, I don't think this is a very commonly-used operation--usually, plotting the uncorrected density is probably a mistake.

Instead, usually what I want is to have log(x) with tick-marks labeled in the original units. Instead of seeing 1, 2, 3... I'd prefer $10, $100, $1000... along the x-axis, to help me interpret the graph in units I understand.

@kapple19
Copy link

+1

@jkrumbiegel
Copy link
Member

Asking for log scales on a density currently results in replacing

I don't get what the issue is, an MWE would be good

@kapple19
Copy link

kapple19 commented Nov 23, 2024

I had a look today and I realise I also don't understand the original question (sorry jkrumbiegel 😅).

Taking the example from the FAQ docs,

log-e x-scale:

julia> using CairoMakie, AlgebraOfGraphics

julia> using AlgebraOfGraphics: density

julia> df = (x = exp.(randn(1000)),)
(x = [0.2902271880952832, 0.7266166553765828, 1.2224270032596198, 1.1556703385577687, 1.039192132661528, 0.5057566035686333, 1.9256338664589439, 0.6326547724870978, 1.4070911916039912, 0.4846729493884399    1.2340141235965212, 1.4771395600162527, 1.6945694302578178, 1.4368012315220762, 2.132316760616112, 0.6859097611065411, 0.2833281990510391, 2.430832649126153, 0.5593374132456983, 0.16772035493995438],)

julia> kde1 = data(df) * mapping(:x) * density()
Layer
  transformation: AlgebraOfGraphics.DensityAnalysis{MakieCore.Automatic, MakieCore.Automatic, MakieCore.Automatic}(MakieCore.Automatic(), 200, MakieCore.Automatic(), MakieCore.Automatic())
  data: AlgebraOfGraphics.Columns{@NamedTuple{x::Vector{Float64}}}
  positional:
    1: x
  named:


julia> draw(kde1, axis=(width=225, height=225, xscale=log,))

Image

linear x-scale:

draw(kde1, axis=(width=225, height=225))

Image

log-10 x-scale:

draw(kde1, axis=(width=225, height=225, xscale=log10,))

Image

In all cases, the x-tick labels are the same "units" as the original data.

@ParadaCarleton what exactly is your problem? As jkrumbiegel said, we'll need a MWE from you. Were you using Unitful.jl?

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