Something that I missed from Excel chart. Notice the y axis is logarithmic scale, but the number label is non logarithmic.

Below is the best I got from Gadfly. The method to set axis limit is also not that friendly. `Coord.Cartesian(ymin=log10(0.1), ymax=log10(1000), xmin=0, xmax=0.5),`

A default y_log10 below.

Is there a way to mimic Excel approach, i.e. linear number for the axis label? Second priority is the major line (with number) and minor line (non-numbered)? Thank you.

You can set the labels manually :

```
Scale.y_log10(labels = x -> "$(10^x)"),
```

You can also put a condition in there, for example when x is not an integer return an empty string. You might have to round the number too.

Itâ€™s indeed not super convenient but you should be able to get what you want with that.

Yes, that does the trick. Nice!

Would you be able to do the minor lines that shouldnâ€™t have label?

I think this should work, set an empty label when x isnâ€™t an integer :

```
Scale.y_log10(labels = x -> mod(x,1) == 0.0 ? "$(10^x)" : "")
```

No change. It is still with major lines only.

```
fn1(x) = (x in -1:x) ? string(10^x) : ""
plot(x=[0, 0.5], y=[0.1, 100], Geom.blank,
Scale.y_log10(labels=fn1),
Guide.yticks(ticks=-1:0.1:2)
)
```

1 Like

The code gives linear minor lines. Modified the code as below.

```
using Gadfly
fn1(x) = (x in -1:x) ? string(10^x) : ""
ylog = []
for x in -1:3
for y in 1:10
push!(ylog, round(log10((y * exp10(x))), digits=1))
end
end
p1 = Gadfly.plot(x=[0, 0.5], y=[0.1, 100], Geom.blank,
#Scale.y_log10(labels=fn1),
Scale.y_log10(labels = x -> mod(x,1) == 0.0 ? "$(10^x)" : ""),
#Guide.yticks(ticks=-1:0.1:2)
Guide.yticks(ticks=ylog, label=true),
)
draw(PDF("logy.pdf", 10inch, 5inch), p1)
```

Sample plot below.

Thanks all.

```
ylog = []
for x in -1:3
for y in 1:10
push!(ylog, round(log10((y * exp10(x))), digits=1))
end
end
```

There must a way to make this code more elegant.

ylog = [round(log10((y * exp10(x))), digits=1) for x in -1:3 for y in 1:10]

2 Likes

Thanks @bjarthur. Thatâ€™s a nice one liner.