Skip to content

Commit d50c9cd

Browse files
Merge pull request #2 from MSD-IRIMAS/aif/fix_read_me
[ENH-BUG] Refactoring README and fix the white axis bug with new version of matplotlib
2 parents 7b8d966 + 61bf915 commit d50c9cd

File tree

8 files changed

+37
-11
lines changed

8 files changed

+37
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ __pycache__/
1414
!heatmap.png
1515
!heatline_vertical.png
1616
!heatline_horizontal.png
17+
!heatmap.pdf
18+
!heatline_horizontal.tex
19+
1720

1821
# Distribution / packaging
1922
.Python

MCM/MCM.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ def draw(
553553

554554
plt.rcParams["figure.autolayout"] = True
555555
fig, ax = plt.subplots(1, 1, figsize=(figsize[0], figsize[1]))
556+
ax.grid(False)
556557

557558
_can_be_negative = False
558559
if colorbar_value is None or colorbar_value == "mean-difference":

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The input format is in a ```.csv``` file containing the statistics of each class
1212

1313
## Usage of Code - Plot the MCM
1414

15-
In order for the user to plot the MCM, first thing is to load the ```.csv``` file into a ```pandas``` dataframe and feed it to the ```compare``` function. The user should specify the ```fig_savename``` parameter in order to save the output figure in ```pdf``` and ```png``` formats.
15+
In order for the user to plot the MCM, first thing is to load the ```.csv``` file into a ```pandas``` dataframe and feed it to the ```compare``` function. The user should specify the ```pdf_savename```, ```png_savename```, ```csv_savename``` or ```tex_savename``` parameter in order to save the output figure in ```pdf```, ```png```, ```csv``` or ```tex``` formats respecively.
1616

1717
## Examples
1818

@@ -29,8 +29,8 @@ output_dir = '/output/directory/desired'
2929
MCM.compare(
3030
output_dir=output_dir,
3131
df_results=df_results,
32-
fig_savename='heatmap',
33-
load_analysis=False
32+
pdf_savename="heatmap",
33+
png_savename="heatmap",
3434
)
3535
```
3636

@@ -52,8 +52,9 @@ MCM.compare(
5252
output_dir=output_dir,
5353
df_results=df_results,
5454
excluded_col_comparates=['clf1','clf3'],
55-
fig_savename='heatline_vertical',
56-
load_analysis=False
55+
png_savename='heatline_vertical',
56+
tex_savename='heatline_vertical',
57+
include_ProbaWinTieLoss=True
5758
)
5859
```
5960

@@ -75,8 +76,8 @@ MCM.compare(
7576
output_dir=output_dir,
7677
df_results=df_results,
7778
excluded_row_comparates=['clf1','clf3'],
78-
fig_savename='heatline_vertical',
79-
load_analysis=False
79+
png_savename='heatline_horizontal',
80+
csv_savename='heatline_horizontal',
8081
)
8182
```
8283

@@ -88,8 +89,9 @@ MCM.compare(
8889

8990
The following python packages are required for the usage of the module:
9091

91-
1. ```numpy==1.23.5```
92-
2. ```pandas==1.5.2```
93-
3. ```matplotlib==3.6.2```
92+
1. ```numpy==1.24.4```
93+
2. ```pandas==2.0.3```
94+
3. ```matplotlib==3.7.4```
9495
4. ```scipy==1.10.0```
9596
5. ```baycomp==1.0```
97+
6. ```tqdm==4.66.1```

heatline_horizontal.png

0 Bytes
Loading

heatline_horizontal.tex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
\documentclass[a4,12pt]{article}
2+
\usepackage{colortbl}
3+
\usepackage{pgfplots}
4+
\usepackage[margin=2cm]{geometry}
5+
\pgfplotsset{compat=newest}
6+
\begin{document}
7+
\begin{table}
8+
\footnotesize
9+
\sffamily
10+
\begin{center}
11+
\begin{tabular}{cccccc}
12+
Mean-Accuracy & \shortstack{clf1 \\ 0.5376} & \shortstack{clf3 \\ 0.5220} & \shortstack{clf2 \\ 0.5123} & \shortstack{clf4 \\ 0.4825} \\[1ex]
13+
\shortstack{clf2 \\ 0.5123} & \cellcolor[rgb]{0.6355,0.7567,0.9983}\shortstack{\rule{0em}{3ex} -0.0253 \\ 60 / 0 / 68 \\ 0.5162} & \cellcolor[rgb]{0.7867,0.8448,0.9398}\shortstack{\rule{0em}{3ex} -0.0097 \\ 64 / 0 / 64 \\ 0.8102} & \cellcolor[rgb]{0.8674,0.8644,0.8626}\shortstack{\rule{0em}{3ex} Mean-Difference \\ r$>$c / r=c / r$<$c \\ Wilcoxon p-value} & \cellcolor[rgb]{0.9649,0.6402,0.5198}\shortstack{\rule{0em}{3ex} 0.0298 \\ 72 / 0 / 56 \\ 0.3880} \\[1ex]
14+
\shortstack{clf4 \\ 0.4825} & \cellcolor[rgb]{0.3286,0.4397,0.8696}\shortstack{\rule{0em}{3ex} -0.0551 \\ 59 / 0 / 69 \\ 0.1018} & \cellcolor[rgb]{0.4839,0.622,0.9748}\shortstack{\rule{0em}{3ex} -0.0395 \\ 58 / 0 / 70 \\ 0.2835} & \cellcolor[rgb]{0.5869,0.7181,0.9989}\shortstack{\rule{0em}{3ex} -0.0298 \\ 56 / 0 / 72 \\ 0.3880} & \cellcolor[rgb]{0.8674,0.8644,0.8626}\shortstack{\rule{0em}{3ex} If in bold, then \\ p-value $<$ 0.05} \\[1ex]
15+
\end{tabular}\\
16+
\begin{tikzpicture}[baseline=(current bounding box.center)]\begin{axis}[hide axis,scale only axis,width=0sp,height=0sp,colorbar horizontal,colorbar style={width=0.25\linewidth,colormap={cm}{rgb255(1)=(83,112,221) rgb255(2)=(220,220,220) rgb255(3)=(209,73,62)},colorbar horizontal,point meta min=-0.07,point meta max=0.07,colorbar/width=1.0em,scaled x ticks=false,xticklabel style={/pgf/number format/fixed,/pgf/number format/precision=3},xlabel={Mean-Difference},}] \addplot[draw=none] {0};\end{axis}\end{tikzpicture}\end{center}
17+
\caption{[...] \textbf{If in bold, then p-value $<$ 0.05} [...]}
18+
\end{table}
19+
\end{document}

heatline_vertical.png

18 KB
Loading

heatmap.pdf

26.3 KB
Binary file not shown.

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from MCM import MCM
44

55
if __name__ == "__main__":
6-
path_res = "./results_example_no_data_column2.csv"
6+
path_res = "./results_example.csv"
77
output_dir = "./"
88

99
df_results = pd.read_csv(path_res)
@@ -18,6 +18,7 @@
1818
df_results=df_results,
1919
excluded_col_comparates=["clf1", "clf3"],
2020
png_savename="heatline_vertical",
21+
include_ProbaWinTieLoss=True
2122
)
2223

2324
MCM.compare(

0 commit comments

Comments
 (0)