3

I want to add this:

enter image description here

I.e. the multiplier f (for femto in this case) to every tick, not only the powers of 10, as is the case already for linear scale. Is it possible to change this behavior?

I would prefer an answer that fixes this automatically by changing the behavior of Plotly, don't want to modify every tick manually.

user171780
  • 2,243
  • 1
  • 20
  • 43

1 Answers1

0

You're trying to modify both the minor and major ticks. Right now nothing's built into Plotly's API to modify the minor tick formatting. However, I found a creative workaround.

You didn't share any programming code. I don't know if you're using a notebook or Plotly express, go, or Plotly as a backend. I don't know how your data is structured or how you called the axis to be log-scaled. That being said, without that information it's difficult to give you a solution that will regardless of what you're working with. (It's always better to share your programming code on a programming forum.)

This uses a Plotly example graph, go, and io. When I use the function io.write_html you may notice that I called several defaults to the defaults. I have to say that the Plotly documentation must not be up to date. The listed defaults are not necessarily defaulted.

This calls for a graph, and Javascript then combines the two into an HTML file that will automatically render in your default browser.

import plotly.graph_objects as go
import plotly.io as io

df = px.data.gapminder().query("year == 2002")
fig = px.scatter(df, x = "gdpPercap", y = "lifeExp", hover_name = "country", log_x = True)

js = '''
setTimeout(function() {
    that = document.querySelectorAll('svg g.xtick')
    that.forEach(el => el.firstChild.innerHTML = el.firstChild.innerHTML + ' f')
}, 200)
'''
io.write_html(fig = fig, file = "fig2.html", post_script = js, 
              full_html = True, include_plotlyjs = 'cdn', auto_open = True)

This reflects a 10k f which is something I doubt anyone would be looking for. However, it doesn't look like your data has that.

enter image description here

Kat
  • 15,669
  • 3
  • 18
  • 51