у меня график строится благодаря коду import pandas as pd import seaborn as sns df78 =…
- User
у меня график строится благодаря коду import pandas as pd import seaborn as sns
df_78 = pd.read_excel('target_final_2.xlsx', dtype=str, index_col=None) df_melt = pd.melt(df_78, id_vars=['Time','target'], value_vars=['first', 'second', 'third'], var_name='sort_1', value_name='value')
df_melt['Time'] = df_melt['Time'].astype(str).astype(int) df_melt['value'] = df_melt['value'].astype(str).astype(int)
Выводим результат
picture= sns.lineplot( x = "Time", y = "value", data = df_melt, errorbar='sd', hue = "target",palette=['red', '#D751C9', 'black', 'orange', '#5170D7', 'green'])
handles, labels = picture.get_legend_handles_labels() label_dict = dict(zip(labels, handles))
new_labels = [ '0 nM', '1 nM', '5 nM', '10 nM', '20 nM','prot'] new_handles = [label_dict[label] for label in new_labels]
#picture.set_title("Заголовок графика", fontsize=16, pad=20) #, fontweight="bold" picture.legend(bbox_to_anchor=(0, 0.8), loc="center left") # сдвиг легенды ближе к оси y , borderaxespad=10 picture.legend(new_handles, new_labels, title="target \nconcentration")
picture.set(xlim=(df_melt['Time'].min(), df_melt['Time'].max())) picture.set(ylim=(0, 80000)) picture.set_xlabel( "Time (min)") picture.set_ylabel( "RFU", fontsize=14)
legend = picture.get_legend() legend.get_frame().set_linewidth(0) sns.despine(top=True, right=True) picture.spines['bottom'].set_linewidth(2) # увеличить толщину нижней оси до 2 picture.spines["left"].set_linewidth(2) # увеличить толщину левой оси до 2
legend.get_title().set_fontsize("8") # установка размера шрифта заголовка легенды legend.set_title("target \nconcentration", prop={"size": 10}) # установка размера заголовка легенды for text in legend.texts: text.set_fontsize("8") # установка размера шрифта самого текста в легенде . МНе нужно поменять текст "prot" на "200 nM, no SPARDA/ "
- Assistant
To change the text "prot" to "200 nM, no SPARDA/" in the legend, you can replace the corresponding label in the new_labels list. Here's the updated code:
new_labels = [ '0 nM', '1 nM', '5 nM', '10 nM', '20 nM','200 nM, no SPARDA/'] new_handles = [label_dict[label] for label in new_labels]
Then, rerun the picture.legend() function with the new_handles and new_labels arguments.
- User
error, no ‘200 nM, no SPARDA/’
- Assistant
If you are getting an error "no ‘200 nM, no SPARDA/’", it might be because this label does not exist in the original data and therefore is not present in the legend.
Double-check your code and make sure that you have correctly replaced the "prot" label with "200 nM, no SPARDA/" in the new_labels list. Also, make sure that the label "200 nM, no SPARDA/" actually exists in the "target" column of your original data.
If the label is still missing, try printing out the unique values in the "target" column to make sure that you are using the correct label name. You can do this with the following code:
print(df_78['target'].unique())Then, adjust the label name in the new_labels list accordingly.
- User
как поменять в столбце df_78[‘target’] значения 'prot' на '200 nM, no SPARDA/"
- Assistant
To replace all occurrences of
'prot'with'200 nM, no SPARDA/'in the'target'column of your DataFramedf_78, you can use the.replace()method. Here's how you can do it:df_78['target'] = df_78['target'].replace('prot', '200 nM, no SPARDA/')This will replace all occurrences of
'prot'with'200 nM, no SPARDA/'in the'target'column ofdf_78.After making this change, you can update the
new_labelslist as follows:new_labels = ['0 nM', '1 nM', '5 nM', '10 nM', '20 nM','200 nM, no SPARDA/'] new_handles = [label_dict[label] for label in new_labels]Then, re-run the
picture.legend()function with the updatednew_handlesandnew_labelsarguments to show the updated legend.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.