追加の質問です。よろしくお願いします。
①dataAとdataBの間隔を狭くする(入力する)方法を教えて下さい。
縦棒を短くしたいです。
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import collections as mc
import seaborn as sns
dataA = [2, 4, 6, 8, 10, 12, 14]
dataB = [3, 6, 9, 12, 15]
data = [['dataA', v] for v in (dataA)] + [['dataB', v] for v in (dataB)]
df = pd.DataFrame(data, columns=['data', 'value'])
ax = sns.stripplot(data=df, x='value', y='data', jitter=False, size=15)
hc = mc.LineCollection(
[[[0, n], [i, n]] for n, i in enumerate(map(max, (dataA, dataB)))],
colors='k', linewidths=2)
ax.add_collection(hc)
lc = mc.LineCollection(
[[[i, 0], [i, 1]] for i in set(dataA).intersection(dataB)],
colors='red', linewidths=2)
ax.add_collection(lc)
for n, l in enumerate((dataA, dataB)):
for i in l:
ax.text(
x=i+0.1, y=n-0.05, s=i,
horizontalalignment='left', verticalalignment='bottom',
size='medium', color='k')
plt.gca().spines['left'].set_visible(False)
plt.gca().spines['top'].set_visible(False)
plt.gca().spines['right'].set_visible(False)
plt.gca().spines['bottom'].set_visible(False)
ax.tick_params(bottom=False,left=False,right=False,top=False)
ax.set_xticks([])
ax.set_xlabel("", size = "large", color ="green")
ax.set_ylabel("", size = "large", color="blue")
plt.show()