1

I would like to represent my data where values go from 0.00001 to 1 where I am interested in plotting data from 0.00001 to 0.1 in a log scale and from 0.1 to 0.95 in linear scale and then again 0.95 to 1 in log scale. Most of the variations happen in the extreme and the data between 0.1 to 0.9 is almost stable but i need to take a look at it though with the rest of the data.

The x axis should be like the one shown below.

enter image description here

bob
  • 33
  • 5
  • What package are you using for plotting? Show us some sample data and sample code that you want to fix. – user2554330 Jul 17 '23 at 20:32
  • Given the tags, I think you are seeking a tool recommendation, which is grounds for closure. I will comment that I am not aware of any tool that would do this out of the box. Your best bet is probably to stitch three plots with the desired ranges and scales together side by side. – bigreddot Jul 17 '23 at 21:12
  • What I did in similar cases is to use a transformation function, maybe something with tan or arctan in your case, and transform the x-axis that way. But consider that others might need to understand your plot, and it's maybe just better to split it into two logarithmic plots next to each other. – Dr. V Jul 17 '23 at 21:21
  • @bigreddot I don't fully agree. It's a non-trivial problem regardless of tool. I do agree with your solution, as posted below. – StephanT Jul 18 '23 at 08:09
  • @StephanT I am not sure what you are disagreeing with. "It's a non-trivial problem regardless of tool" is exactly what I meant by "I am not aware of any tool that would do this out of the box." – bigreddot Jul 18 '23 at 15:34
  • @bigreddot I didn't agree with closure. As there is no tool with out-of-the-box solution, the question seems valid to me. It would only be lacking a code attempt. – StephanT Jul 18 '23 at 18:16
  • Lacking a code attempt is also grounds for closure... – bigreddot Jul 18 '23 at 22:13

1 Answers1

1

This is possible by splitting the graphing in three parts and assigning each to its own x-axis. These x-axes can be placed next to each other by specifying the domain (relative coverage of space). This is in Python, but Plotly should have the same functionality in R.

import plotly.graph_objects as go

x1 = [0.001,0.01,0.1]
x2 = [10,100,1000]
x3 = [1000,10000,100000]

y1 = [1,2,3]
y2 = [4,5,6]
y3 = [7,8,9]

fig = go.Figure()

fig.add_trace(go.Scatter(x=x1, y=y1, xaxis='x1'))
fig.add_trace(go.Scatter(x=x2, y=y2, xaxis='x2'))
fig.add_trace(go.Scatter(x=x3, y=y3, xaxis='x3'))

fig.update_layout(
    xaxis1=dict(
        range=[-3,0],
        side='bottom',
        overlaying='x',
        domain=[0,0.35],
        type='log'
        ),
    xaxis2=dict(
        range=[1,1000],
        side='bottom',
        overlaying='x',
        domain=[.35,.65],
        ),
    xaxis3=dict(
        range=[3,6],
        side='bottom',
        overlaying='x',
        domain=[.65,1],
        type='log'
        ),
    )

x axes with different scales

StephanT
  • 649
  • 5
  • 12