# Prepare Python environment
import scipy.io as sio
import numpy as np
from pathlib import Path
data_dir = Path("../../../data/06-MT-02-MTR")
data_file = "fig6.mat"
#Load either archived or generated plot variables
mat_contents = sio.loadmat(data_dir / data_file)
MTRs = mat_contents["MTRs"][0]
TR = mat_contents["TR_range"][0]
TR_true = mat_contents["trueTR"][0]
x_TR_true = np.ones(len(MTRs))*TR_true
y_TR_true = np.linspace(MTRs[-1]*0.95, MTRs[0]*1.05, num=len(MTRs))
# Plot Figure 1
# Module imports
import matplotlib.pyplot as plt
import plotly as py
import plotly.graph_objs as go
import numpy as np
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
config={'showLink': False, 'displayModeBar': False}
init_notebook_mode(connected=True)
# PYTHON CODE
init_notebook_mode(connected=True)
# The polling here is to ensure that plotly.js has already been loaded before
# setting display alignment in order to avoid a race condition.
data = [
go.Scatter(
x=TR,
y=MTRs,
name = "Protocol: Brown 2013 (Philips)",
text = 'N/A',
hoverinfo = 'y'
),
go.Scatter(
x=x_TR_true,
y=y_TR_true,
name = "True TR",
text = 'N/A',
hoverinfo = 'y',
line = dict(shape = 'linear', color = 'rgb(0, 0, 0)', width = 2, dash = 'dash'),
),
]
layout = go.Layout(
width=600,
height=600,
margin=go.layout.Margin(
l=100,
r=80,
b=100,
t=130,
),
annotations=[
dict(
x=-0.15,
y=0.50,
showarrow=False,
text='MTR',
font=dict(
family='Times New Roman',
size=22
),
textangle=-90,
xref='paper',
yref='paper'
),
dict(
x=0.5,
y=-0.15,
showarrow=False,
text='TR (ms)',
font=dict(
family='Times New Roman',
size=22
),
textangle=0,
xref='paper',
yref='paper'
),
],
xaxis=dict(
showgrid=True,
gridcolor='rgb(169,169,169)',
linecolor='black',
linewidth=2
),
yaxis=dict(
showgrid=True,
gridcolor='rgb(169,169,169)',
linecolor='black',
linewidth=2,
range = [0.36, 0.5]
),
legend=dict(
x=0.25,
y=1.2,
traceorder='normal',
font=dict(
family='Times New Roman',
size=12,
color='#000'
),
bordercolor='#000000',
borderwidth=2
)
)
fig = dict(data=data, layout=layout)
iplot(fig, filename = 'fig7.html', config = config)
Loading...