Plots.jl series_annotations in log space?

I’m trying to make a simple scatter plot with annotations beside each point. The annotations plot just fine until I try to log the points and then they don’t appear at all. Does anyone know what I’m doing wrong? Thanks!

Here are the data and the code:
using Plots
means_star = [0.0 0.005526406192322886 799.8267497946407 177.82849202167688 2.949944562884643 2.355964803138008 0.08124614666269785 0.024034307014446792 88.48828541928569 1.9044308225116957 1.695190231560464e-5 1.7062877208175246e-5 90.02136461101408 1.7848945313037565 1341.9178923513505 0.01499287865610195 0.04482490303504983 1.4557719588379853e-5 6.839274651318975e-8 5.8261106263881655e-8 9.837706558654697 0.13246461533024648 3.217222585151145e-5 0.00014272790609066738 597.226810012124 1.3740478802906948 0.00016152623914047397 3.815908073139803e-5 0.13900797726857567 0.47892429760166594 2.9390276329784255 4.813845379195557 0.007949209102676493 0.15953309813912905 0.0001070094238071111 0.008823310615810223 5014.198605023984 614794.9049986276 0.0034212880890896473 10.51155321028209]

variances = [0.0 0.0003323567976011983 2.4431312944107647e6 378087.16763153207 43.01980287797502 29.77328458294959 0.007325998516859202 0.004595928640274562 52398.04526000891 2.906193240838542 9.114837251498614e-10 1.5380622674896094e-9 41667.01086641929 6.316932866493318 9.011390290339632e6 0.0018322915114565885 0.020272411539561844 8.923553097248263e-10 5.03203863000008e-14 3.667744201376821e-14 256.2085680724384 0.04685272105130505 5.827276878177216e-9 1.366483298914779e-7 1.6210905686773888e6 5.842250530692976 7.933373701400965e-8 4.18551767624787e-9 0.05285819539135993 0.7694332346657032 59.46953233009331 115.18433151268985 0.00045097306280370843 0.19804381945492414 2.5383866580738188e-8 0.0009857872253883147 2.5148570779390782e8 1.7471751842715537e12 0.00018526675531781278 180.83439642829998]

pn = ["r","rS","bₕ", "bₛₐ","b_S_E","b_S_EL","b_S_TL","lambda","μWₐ","mu_W_E", "mu_W_EH", "mu_W_TH","Φₐ", "Φₑ", "μₚ", "tauM", "mu_U_a","mu_U_E","mu_U_EH", "mu_U_TH", "μᵢₐ", "mu_I_E", "mu_I_EH", "mu_I_TH", "μₑₐ","mu_E_E","mu_E_EH","mu_E_TH","tauU_a", "tauU_E", "tauU_EL","tauU_TL", "tauI_a", "tauI_E","tauI_EL","tauI_EL","ϕₕ", "c", "S","H"]

#This works but is illegible
scatter(means_star', variances', label = "",xlabel = "μ*",series_annotations=text.(pn,:top,12), ylabel = "σ")

#This plots much clearer, but annotations don’t appear
scatter(log.(means_star'), log.(variances'), label = "", xlabel = "μ*",series_annotations=text.(pn,:top,12), ylabel = "σ")

1 Like

You are calculating log(0) in your second example. The code will work in some Plots.jl backends (ex: pyplot() or pgfplotsx()) if you take care of the zeros.

One option is to use scale=:log10 in your first example and to exclude the zeros using appropriate xlims and ylims.

Example using Plots; pyplot():

scatter(means_star', variances', label="", xlabel="μ*", ylabel="σ", series_annotations=text.(pn,:top,12), scale=:log10, xlims=(1e-10, 1e10), ylims=(1e-20, 1e20))

1 Like

That’s great, thanks! Logging the zero was the problem. In addition to your suggestion, it also works to just add 1e-20 to that zero before logging.