In plotly, is there a way to display a given axis' ticks in hexadecimal format rather than as a large scientific number? This is useful to plot address traces
You can do this with [str(hex(elem)) for elem in [1000000, ..., 5000000]
Plot:

Some details to be aware of:
To my knowledge you'll have to use a list of type string to obtain the desired behavior. Values such as [1000000, 2000000, 3000000, 4000000, 5000000] will by default be displayed as:

And that will happen even for [str(hex(elem)) for elem in xVals]. So you'll have to explicitly instruct plotly to display the ticks as strings with:
fig.update_xaxes(tickmode = 'array',
tickvals = xHex,
ticktext= xHex)
Complete code:
# imports
import plotly.express as px
import plotly.graph_objs as go
import pandas as pd
import numpy as np
import plotly.express as px
xVals = [1000000, 2000000, 3000000, 4000000, 5000000]
xHex = [str(hex(elem)) for elem in xVals]
fig = px.scatter(x=xHex, y=[0, 1, 4, 9, 16])
fig.show()
fig.update_xaxes(tickmode = 'array',
tickvals = xHex,
ticktext= xHex)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With