finished plot in chasing

This commit is contained in:
wendtalexander 2023-01-26 11:36:12 +01:00
parent 238e36434d
commit a32d91309f
9 changed files with 77 additions and 59 deletions

View File

@ -110,7 +110,7 @@ def PlotStyle() -> None:
plt.setp(bp["boxes"], color=color) plt.setp(bp["boxes"], color=color)
plt.setp(bp["whiskers"], color=white) plt.setp(bp["whiskers"], color=white)
plt.setp(bp["caps"], color=white) plt.setp(bp["caps"], color=white)
plt.setp(bp["medians"], color=white) plt.setp(bp["medians"], color=black)
@classmethod @classmethod
@ -255,10 +255,10 @@ def PlotStyle() -> None:
plt.rcParams["boxplot.boxprops.color"] = gray plt.rcParams["boxplot.boxprops.color"] = gray
plt.rcParams["boxplot.whiskerprops.color"] = gray plt.rcParams["boxplot.whiskerprops.color"] = gray
plt.rcParams["boxplot.capprops.color"] = gray plt.rcParams["boxplot.capprops.color"] = gray
plt.rcParams["boxplot.medianprops.color"] = gray plt.rcParams["boxplot.medianprops.color"] = black
plt.rcParams["text.color"] = white plt.rcParams["text.color"] = white
plt.rcParams["axes.facecolor"] = black # axes background color plt.rcParams["axes.facecolor"] = black # axes background color
plt.rcParams["axes.edgecolor"] = gray # axes edge color plt.rcParams["axes.edgecolor"] = white # axes edge color
# plt.rcParams["axes.grid"] = True # display grid or not # plt.rcParams["axes.grid"] = True # display grid or not
# plt.rcParams["axes.grid.axis"] = "y" # which axis the grid is applied to # plt.rcParams["axes.grid.axis"] = "y" # which axis the grid is applied to
plt.rcParams["axes.labelcolor"] = white plt.rcParams["axes.labelcolor"] = white
@ -284,9 +284,9 @@ def PlotStyle() -> None:
"#f5c2e7", "#f5c2e7",
], ],
) )
plt.rcParams["xtick.color"] = gray # color of the ticks plt.rcParams["xtick.color"] = white # color of the ticks
plt.rcParams["ytick.color"] = gray # color of the ticks plt.rcParams["ytick.color"] = white # color of the ticks
plt.rcParams["grid.color"] = dark_gray # grid color plt.rcParams["grid.color"] = white # grid color
plt.rcParams["figure.facecolor"] = black # figure face color plt.rcParams["figure.facecolor"] = black # figure face color
plt.rcParams["figure.edgecolor"] = black # figure edge color plt.rcParams["figure.edgecolor"] = black # figure edge color
plt.rcParams["savefig.facecolor"] = black # figure face color when saving plt.rcParams["savefig.facecolor"] = black # figure face color when saving

View File

@ -252,9 +252,9 @@ def main(datapath: str):
size_loser_pearsonr = pearsonr(size_diffs_loser, size_chirps_loser) size_loser_pearsonr = pearsonr(size_diffs_loser, size_chirps_loser)
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=( fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(
21*ps.cm, 10*ps.cm), width_ratios=[1, 0.8, 0.8], sharey=True) 21*ps.cm, 8*ps.cm), width_ratios=[1, 0.8, 0.8], sharey=True)
plt.subplots_adjust(left=0.11, right=0.948, top=0.905, plt.subplots_adjust(left=0.11, right=0.948, top=0.86,
wspace=0.343, bottom=0.145) wspace=0.343, bottom=0.18)
scatterwinner = 1.15 scatterwinner = 1.15
scatterloser = 1.85 scatterloser = 1.85
chirps_winner = np.asarray(chirps_winner)[~np.isnan(chirps_winner)] chirps_winner = np.asarray(chirps_winner)[~np.isnan(chirps_winner)]
@ -262,47 +262,51 @@ def main(datapath: str):
stat = wilcoxon(chirps_winner, chirps_loser) stat = wilcoxon(chirps_winner, chirps_loser)
print(stat) print(stat)
winner_color = ps.lavender
loser_color = ps.purple
bplot1 = ax1.boxplot(chirps_winner, positions=[ bplot1 = ax1.boxplot(chirps_winner, positions=[
0.9], showfliers=False, patch_artist=True) 0.9], showfliers=False, patch_artist=True)
bplot2 = ax1.boxplot(chirps_loser, positions=[ bplot2 = ax1.boxplot(chirps_loser, positions=[
2.1], showfliers=False, patch_artist=True) 2.1], showfliers=False, patch_artist=True)
ax1.scatter(np.ones(len(chirps_winner)) * ax1.scatter(np.ones(len(chirps_winner)) *
scatterwinner, chirps_winner, color=ps.red) scatterwinner, chirps_winner, color=winner_color)
ax1.scatter(np.ones(len(chirps_loser)) * ax1.scatter(np.ones(len(chirps_loser)) *
scatterloser, chirps_loser, color=ps.orange) scatterloser, chirps_loser, color=loser_color)
ax1.set_xticklabels(['winner', 'loser']) ax1.set_xticklabels(['Winner', 'Loser'])
ax1.text(0.1, 0.95, f'n={len(chirps_winner)}', transform=ax1.transAxes, color=ps.white) ax1.text(0.1, 0.95, f'n={len(chirps_winner)}',
transform=ax1.transAxes, color=ps.white)
for w, l in zip(chirps_winner, chirps_loser): for w, l in zip(chirps_winner, chirps_loser):
ax1.plot([scatterwinner, scatterloser], [w, l], ax1.plot([scatterwinner, scatterloser], [w, l],
color=ps.white, alpha=1, linewidth=0.5) color=ps.white, alpha=0.6, linewidth=1, zorder=-1)
ax1.set_ylabel('chirpcounts', color=ps.white) ax1.set_ylabel('Chirp counts', color=ps.white)
ax1.set_xlabel('outcome', color=ps.white) ax1.set_xlabel('Competition outcome', color=ps.white)
colors1 = ps.red ps.set_boxplot_color(bplot1, winner_color)
ps.set_boxplot_color(bplot1, colors1) ps.set_boxplot_color(bplot2, loser_color)
colors1 = ps.orange
ps.set_boxplot_color(bplot2, colors1)
ax2.scatter(size_diffs_winner, size_chirps_winner, ax2.scatter(size_diffs_winner, size_chirps_winner,
color=ps.red, label=f'winner') color=winner_color, label=f'Winner')
ax2.scatter(size_diffs_loser, size_chirps_loser, ax2.scatter(size_diffs_loser, size_chirps_loser,
color=ps.orange, label='loser') color=loser_color, label='Loser')
ax2.text(0.05, 0.95, f'n={len(size_chirps_winner)}', transform=ax2.transAxes, color=ps.white) ax2.text(0.05, 0.95, f'n={len(size_chirps_winner)}',
transform=ax2.transAxes, color=ps.white)
ax2.set_xlabel('size difference [cm]') ax2.set_xlabel('Size difference [cm]')
# ax2.set_xticks(np.arange(-10, 10.1, 2)) # ax2.set_xticks(np.arange(-10, 10.1, 2))
ax3.scatter(freq_diffs_higher, freq_chirps_winner, color=ps.red) ax3.scatter(freq_diffs_higher, freq_chirps_winner, color=winner_color)
ax3.scatter(freq_diffs_lower, freq_chirps_loser, color=ps.orange) ax3.scatter(freq_diffs_lower, freq_chirps_loser, color=loser_color)
ax3.text(0.1, 0.95, f'n={len(freq_chirps_loser)}', transform=ax3.transAxes, color=ps.white) ax3.text(0.1, 0.95, f'n={len(freq_chirps_loser)}',
transform=ax3.transAxes, color=ps.white)
ax3.set_xlabel('absolute frequency [Hz]') ax3.set_xlabel('EODf [Hz]')
handles, labels = ax2.get_legend_handles_labels() handles, labels = ax2.get_legend_handles_labels()
fig.legend(handles, labels, loc='upper center', ncol=2) fig.legend(handles, labels, loc='upper center', ncol=2)
# pearson r # pearson r

View File

@ -45,33 +45,46 @@ def main(datapath: str):
chirps_in_chasings = [] chirps_in_chasings = []
for onset, offset in zip(chasing_onset, chasing_offset): for onset, offset in zip(chasing_onset, chasing_offset):
chirps_in_chasing = [c for c in bh.chirps if (c > onset) & (c < offset)] chirps_in_chasing = [
c for c in bh.chirps if (c > onset) & (c < offset)]
chirps_in_chasings.append(chirps_in_chasing) chirps_in_chasings.append(chirps_in_chasing)
try: try:
time_chasing = np.sum(chasing_offset[chasing_offset<3*60*60] - chasing_onset[chasing_onset<3*60*60]) time_chasing = np.sum(
chasing_offset[chasing_offset < 3*60*60] - chasing_onset[chasing_onset < 3*60*60])
except: except:
time_chasing = np.sum(chasing_offset[chasing_offset<3*60*60] - chasing_onset[chasing_onset<3*60*60][:-1]) time_chasing = np.sum(
chasing_offset[chasing_offset < 3*60*60] - chasing_onset[chasing_onset < 3*60*60][:-1])
time_chasing_percent = (time_chasing/(3*60*60))*100 time_chasing_percent = (time_chasing/(3*60*60))*100
chirps_chasing = np.asarray(flatten(chirps_in_chasings)) chirps_chasing = np.asarray(flatten(chirps_in_chasings))
chirps_chasing_new = chirps_chasing[chirps_chasing<3*60*60] chirps_chasing_new = chirps_chasing[chirps_chasing < 3*60*60]
chirps_percent = (len(chirps_chasing_new)/len(bh.chirps[bh.chirps<3*60*60]))*100 chirps_percent = (len(chirps_chasing_new) /
len(bh.chirps[bh.chirps < 3*60*60]))*100
time_precents.append(time_chasing_percent) time_precents.append(time_chasing_percent)
chirps_percents.append(chirps_percent) chirps_percents.append(chirps_percent)
fig, ax = plt.subplots(1, 1, figsize=(14*ps.cm, 10*ps.cm)) fig, ax = plt.subplots(1, 1, figsize=(7*ps.cm, 7*ps.cm))
scatter_time = 1.20
ax.boxplot([time_precents, chirps_percents]) scatter_chirps = 1.80
ax.set_xticklabels(['Time Chasing', 'Chirps in Chasing']) size = 10
bplot1 = ax.boxplot([time_precents, chirps_percents],
showfliers=False, patch_artist=True)
ps.set_boxplot_color(bplot1, ps.gray)
ax.set_xticklabels(['Time \nChasing', 'Chirps \nin Chasing'])
ax.set_ylabel('Percent') ax.set_ylabel('Percent')
ax.scatter(np.ones(len(time_precents))*1.25, time_precents, color=ps.white) ax.scatter(np.ones(len(time_precents))*scatter_time, time_precents,
ax.scatter(np.ones(len(chirps_percents))*1.75, chirps_percents, color=ps.white) facecolor=ps.white, s=size)
ax.scatter(np.ones(len(chirps_percents))*scatter_chirps, chirps_percents,
facecolor=ps.white, s=size)
for i in range(len(time_precents)): for i in range(len(time_precents)):
ax.plot([1.25, 1.75], [time_precents[i], chirps_percents[i]], color=ps.white) ax.plot([scatter_time, scatter_chirps], [time_precents[i],
ax.text(0.99, 0.99, f'{len(time_precents)} fish', transform=ax.transAxes) chirps_percents[i]], alpha=0.6, linewidth=1, color=ps.white)
ax.text(0.1, 0.9, f'n={len(time_precents)}', transform=ax.transAxes)
plt.subplots_adjust(left=0.221, bottom=0.186, right=0.97, top=0.967)
plt.savefig('../poster/figs/chirps_in_chasing.pdf') plt.savefig('../poster/figs/chirps_in_chasing.pdf')
plt.show() plt.show()
@ -80,5 +93,3 @@ if __name__ == '__main__':
# Path to the data # Path to the data
datapath = '../data/mount_data/' datapath = '../data/mount_data/'
main(datapath) main(datapath)

View File

@ -79,7 +79,6 @@ def main(datapath: str):
ax[0].set_xticks([]) ax[0].set_xticks([])
ax[0].set_yticks([]) ax[0].set_yticks([])
ps.hide_ax(ax[0]) ps.hide_ax(ax[0])
ax[0].yaxis.set_label_coords(-0.1, 0.5)
ax[1].grid(False) ax[1].grid(False)
ax[1].set_frame_on(False) ax[1].set_frame_on(False)
@ -99,19 +98,23 @@ def main(datapath: str):
labelpad = 30 labelpad = 30
fsize = 12 fsize = 12
ax[0].set_ylabel('contact', rotation=0,
ax[0].set_ylabel('Contact', rotation=0,
labelpad=labelpad, fontsize=fsize) labelpad=labelpad, fontsize=fsize)
ax[1].set_ylabel('chasing', rotation=0, ax[0].yaxis.set_label_coords(-0.062, -0.08)
ax[1].set_ylabel('Chasing', rotation=0,
labelpad=labelpad, fontsize=fsize) labelpad=labelpad, fontsize=fsize)
ax[2].set_ylabel('chirps', rotation=0, ax[1].yaxis.set_label_coords(-0.06, -0.08)
ax[2].set_ylabel('Chirps', rotation=0,
labelpad=labelpad, fontsize=fsize) labelpad=labelpad, fontsize=fsize)
ax[2].yaxis.set_label_coords(-0.07, -0.08)
ax[4].set_ylabel('EODf') ax[4].set_ylabel('EODf')
ax[4].set_xlabel('time [h]') ax[4].set_xlabel('Time [h]')
# ax[0].set_title(foldername.split('/')[-2]) # ax[0].set_title(foldername.split('/')[-2])
# 2020-03-31-9_59 # 2020-03-31-9_59
plt.subplots_adjust(left=0.158, right=0.987, top=0.918) plt.subplots_adjust(left=0.158, right=0.987, top=0.918, bottom=0.136)
# plt.savefig('../poster/figs/timeline.pdf') plt.savefig('../poster/figs/timeline.pdf')
plt.show() plt.show()
# plot chirps # plot chirps

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,20 +22,20 @@ blockverticalspace=2mm, colspace=20mm, subcolspace=0mm]{tikzposter} %Default val
weakly electric fish impossible. This profoundly limits our current weakly electric fish impossible. This profoundly limits our current
understanding of chirps to experiments understanding of chirps to experiments
with single - or physically separated - individuals. with single - or physically separated - individuals.
% \begin{tikzfigure}[] \begin{tikzfigure}[]
% \label{griddrawing} \label{griddrawing}
% \includegraphics[width=0.8\linewidth]{figs/introplot} \includegraphics[width=0.6\linewidth]{figs/introplot}
% \end{tikzfigure} \end{tikzfigure}
} }
\myblock[TranspBlock]{Chirp detection}{ \myblock[TranspBlock]{Chirp detection}{
\begin{tikzfigure}[] \begin{tikzfigure}[]
\label{fig:alg1} \label{fig:alg1}
\includegraphics[width=0.9\linewidth]{figs/algorithm1} \includegraphics[width=0.6\linewidth]{figs/algorithm1}
\end{tikzfigure} \end{tikzfigure}
\vspace{2cm} \vspace{2cm}
\begin{tikzfigure}[] \begin{tikzfigure}[]
\label{fig:alg2} \label{fig:alg2}
\includegraphics[width=1\linewidth]{figs/algorithm} \includegraphics[width=0.9\linewidth]{figs/algorithm}
\end{tikzfigure} \end{tikzfigure}
\vspace{0cm} \vspace{0cm}
} }
@ -63,8 +63,8 @@ blockverticalspace=2mm, colspace=20mm, subcolspace=0mm]{tikzposter} %Default val
\begin{itemize} \begin{itemize}
\setlength\itemsep{0.5em} \setlength\itemsep{0.5em}
\item Fish who won the competition chirped more often than the fish who lost. \item Fish who lost the competition chirped more often than the fish who lost.
\item \item Size has an effect on the Competition outcome, and the chirp count.
\end{itemize} \end{itemize}
} }