Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Scatterplots & lot of bar plot fixes #270

Merged
merged 36 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5d23b48
minor docstring change
MerktSimon Jan 7, 2020
f926a1e
fixes #196
MerktSimon Jan 7, 2020
1b5714c
flake8
MerktSimon Jan 9, 2020
64b8f48
resolves #210
MerktSimon Jan 15, 2020
e73d247
resolved merging changes with new develop branch
MerktSimon Jan 15, 2020
5fbd7fa
Flake8
MerktSimon Jan 15, 2020
e6641be
solves #213 in both ways
MerktSimon Jan 15, 2020
7545f71
Flake8
MerktSimon Jan 15, 2020
0d2d2f3
Merge branch 'develop' into fixes_sm
MerktSimon Jan 22, 2020
fe8b117
Codacity
MerktSimon Jan 22, 2020
d8e301c
Merge remote-tracking branch 'origin/fixes_sm' into fixes_sm
MerktSimon Jan 22, 2020
98bff87
Codacity
MerktSimon Jan 22, 2020
409b824
Merge branch 'develop' into fixes_sm
MerktSimon Jan 23, 2020
ed3a033
minor changes
MerktSimon Jan 23, 2020
3d3b3a2
Merge branch 'fixes_sm' of https://github.com/ICB-DCM/PEtab into fixe…
MerktSimon Jan 23, 2020
25d435c
resolves #197
MerktSimon Jan 27, 2020
f44b2da
small fix
MerktSimon Jan 27, 2020
b22d40c
change all barplot colors to blue
MerktSimon Feb 6, 2020
377a5a0
resolve merging conflicts
MerktSimon Feb 6, 2020
a1ea553
fix codacy complaints
MerktSimon Feb 6, 2020
8d5a5b0
travis
MerktSimon Feb 6, 2020
700632f
adjust angle for barplot ticks
MerktSimon Feb 6, 2020
75cf6d8
implementing scatter plots (resolves #263)
MerktSimon Feb 6, 2020
799bfb5
merge develop
MerktSimon Feb 6, 2020
06fed88
small stuff
MerktSimon Feb 7, 2020
72bbb25
barplot: fix noise, legend
MerktSimon Feb 7, 2020
87f83df
Merge branch 'develop' into hackathon_sm
MerktSimon Feb 7, 2020
006412e
Merge branch 'develop' into hackathon_sm
dweindl Feb 10, 2020
2a6e7f0
Merge branch 'develop' into hackathon_sm
yannikschaelte Feb 17, 2020
b41d11f
Merge branch 'develop' into hackathon_sm
yannikschaelte Feb 20, 2020
b1b4e5f
Merge branch 'develop' into hackathon_sm
yannikschaelte Feb 24, 2020
204b868
Merge branch 'develop' into hackathon_sm
dweindl Feb 25, 2020
7d50866
make scatterplots square
MerktSimon Feb 26, 2020
9e43527
Merge branch 'hackathon_sm' of https://github.com/PEtab-dev/PEtab int…
MerktSimon Feb 26, 2020
7db88d5
small fix
MerktSimon Feb 26, 2020
657b4bd
Merge branch 'develop' into hackathon_sm
MerktSimon Feb 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
barplot: fix noise, legend
  • Loading branch information
MerktSimon committed Feb 7, 2020
commit 72bbb25462173d372df86f598dcbbc5f35933007
16 changes: 8 additions & 8 deletions doc/example/example_visualization.ipynb

Large diffs are not rendered by default.

60 changes: 35 additions & 25 deletions petab/visualize/plotting_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ def plot_lowlevel(vis_spec: pd.DataFrame,
elif vis_spec.yScale[i_visu_spec] == LOG:
ax[axx, axy].set_yscale("log", basey=np.e)

# set type of noise
if vis_spec[PLOT_TYPE_DATA][i_visu_spec] == MEAN_AND_SD:
noise_col = 'sd'
elif vis_spec[PLOT_TYPE_DATA][i_visu_spec] == MEAN_AND_SEM:
noise_col = 'sem'
elif vis_spec[PLOT_TYPE_DATA][i_visu_spec] == PROVIDED:
noise_col = 'noise_model'

if vis_spec.plotTypeSimulation[i_visu_spec] == LINE_PLOT:

# equidistant
Expand All @@ -91,31 +99,18 @@ def plot_lowlevel(vis_spec: pd.DataFrame,
# TODO sort mean and sd/sem by x values (as for simulatedData below)
# to avoid crazy lineplots in case x values are not sorted by default.
# cf issue #207
#
# construct errorbar-plots: Mean and standard deviation
label_base = vis_spec[ind_plot][LEGEND_ENTRY][i_visu_spec]
if vis_spec[PLOT_TYPE_DATA][i_visu_spec] == MEAN_AND_SD:
p = ax[axx, axy].errorbar(
conditions, ms['mean'], ms['sd'], linestyle='-.', marker='.',
label=label_base)

# construct errorbar-plots: Mean and standard error of mean
elif vis_spec[PLOT_TYPE_DATA][i_visu_spec] == MEAN_AND_SEM:
p = ax[axx, axy].errorbar(
conditions, ms['mean'], ms['sem'], linestyle='-.', marker='.',
label=label_base)

# plotting all measurement data
elif vis_spec[PLOT_TYPE_DATA][i_visu_spec] == REPLICATE:
label_base = vis_spec[ind_plot][LEGEND_ENTRY][i_visu_spec]
if vis_spec[PLOT_TYPE_DATA][i_visu_spec] == REPLICATE:
p = ax[axx, axy].plot(
conditions[conditions.index.values],
ms.repl[ms.repl.index.values], 'x',
label=label_base)

# construct errorbar-plots: Mean and noise provided in measurement file
elif vis_spec[PLOT_TYPE_DATA][i_visu_spec] == PROVIDED:
# construct errorbar-plots: noise specified above
else:
p = ax[axx, axy].errorbar(
conditions, ms['mean'], ms['noise_model'],
conditions, ms['mean'], ms[noise_col],
linestyle='-.', marker='.', label=label_base)
# construct simulation plot
colors = p[0].get_color()
Expand All @@ -128,19 +123,33 @@ def plot_lowlevel(vis_spec: pd.DataFrame,
# construct bar plot
elif vis_spec[PLOT_TYPE_SIMULATION][i_visu_spec] == BAR_PLOT:
x_name = vis_spec[ind_plot][LEGEND_ENTRY][i_visu_spec]
print(x_name)
p = ax[axx, axy].bar(x_name, ms['mean'], yerr=ms['sd'],
color=sns.color_palette()[0])
ax[axx, axy].set_xticks(x_name)
ind_bars = vis_spec[ind_plot][PLOT_TYPE_SIMULATION] == BAR_PLOT
x_names = list(vis_spec[ind_plot][ind_bars][LEGEND_ENTRY])
p = ax[axx, axy].bar(x_name, ms['mean'], yerr=ms[noise_col],
color=sns.color_palette()[0], width=2/3)
legend = ['measurement']
tick_factor = 1
tick_offset = 0

if plot_sim:
colors = p[0].get_facecolor()
ax[axx, axy].bar(x_name + " simulation", ms['sim'], color='white',
width=-0.8, align='edge', edgecolor=colors)
width=-2/3, align='edge', edgecolor=colors)
legend.append('simulation')
tick_factor = 2
tick_offset = 1/3

x_ticks = tick_factor * np.linspace(0, len(x_names) - 1,
len(x_names)) + tick_offset
ax[axx, axy].set_xticks(x_ticks)
ax[axx, axy].set_xticklabels(x_names)

for label in ax[axx, axy].get_xmajorticklabels():
label.set_rotation(30)
label.set_horizontalalignment("right")

ax[axx, axy].legend(legend)

# construct scatter plot
elif vis_spec[PLOT_TYPE_SIMULATION][i_visu_spec] == SCATTER_PLOT:
if not plot_sim:
Expand All @@ -158,8 +167,9 @@ def ticks(y, _):
ax[axx, axy].yaxis.set_major_formatter(mtick.FuncFormatter(ticks))

# set further plotting/layout settings
print('debug')
ax[axx, axy].legend()

if not vis_spec[PLOT_TYPE_SIMULATION][i_visu_spec] == BAR_PLOT:
ax[axx, axy].legend()
ax[axx, axy].set_title(vis_spec[PLOT_NAME][i_visu_spec])
ax[axx, axy].relim()
ax[axx, axy].autoscale_view()
Expand Down