Skip to content

Commit 21a46b9

Browse files
Added python file with symlogish example.
1 parent 37e4577 commit 21a46b9

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

dash_symlog.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import numpy as np
2+
import plotly.graph_objects as go
3+
import dash
4+
import dash_core_components as dcc
5+
import dash_html_components as html
6+
7+
# Create data
8+
def gaussian(x,mu,sig):
9+
return np.exp(-0.5*np.power((x-mu)/sig, 2))
10+
11+
xLinGs = np.linspace(-1.0,1,1000)
12+
xLogGs = np.logspace(0,4,10000)
13+
xGs = np.concatenate((xLinGs,xLogGs))
14+
yGs = gaussian(xGs,0,0.25) + gaussian(xGs,10,2.5) + \
15+
gaussian(xGs,100,25) + gaussian(xGs,1000,250) + \
16+
gaussian(xGs,10000,2500)
17+
18+
# Create figure
19+
fig = go.Figure()
20+
fig.add_trace(
21+
go.Scatter(x=xGs, y=yGs, name='Linear', xaxis='x1', line_color='red')
22+
)
23+
fig.add_trace(
24+
go.Scatter(x=xGs, y=yGs, name='Log', xaxis='x2', line_color='blue')
25+
)
26+
domFrac = 1.0/3.0 # distance from 0 to 1 same as 10 to 100
27+
fig.update_layout(
28+
title_text='Simple Symmetrical Log (symlog) Example',
29+
xaxis={
30+
'domain':[0,domFrac],
31+
'range':[-1.0,0.999] # prevent an additional '1' on x-axis
32+
},
33+
xaxis2={
34+
'domain':[domFrac,1],
35+
'range':[0,4],
36+
'title':'Time',
37+
'type':'log',
38+
'dtick':'D1'
39+
},
40+
yaxis={
41+
'title':'Amplitude'
42+
}
43+
)
44+
45+
# Create app
46+
app = dash.Dash()
47+
app.layout = html.Div([
48+
dcc.Graph(figure=fig)
49+
])
50+
51+
# Run app
52+
app.run_server(debug=True)

0 commit comments

Comments
 (0)