日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python seaborn boxplot_python - 如何将文本框添加到Seaborn Boxplot? - 堆栈内存溢出

發布時間:2023/12/20 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python seaborn boxplot_python - 如何将文本框添加到Seaborn Boxplot? - 堆栈内存溢出 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我試圖在框圖中插入一個文本框,但是出了點問題。 讓我們先繪制箱線圖:

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sb

df_data = pd.read_hdf('data.h5', key=f'df_data')

##print(df_data)

fig, (ax1, ax2) = plt.subplots(1,

2,

gridspec_kw={'width_ratios': [3, 1]})

my_pal = {'PtP':'dodgerblue', 'T1':'salmon', 'T2':'salmon', 'E':'limegreen'}

sb.boxplot(data=df_data[['PtP', 'T1', 'T2']], ax=ax1, palette=my_pal)

sb.boxplot(data=df_data[['E']], ax=ax2, palette=my_pal)

posx = 1500

posy = 'T1'

##ax1.text(posx,

## posy,

## f'Average Impulse Interval: Over9000',

## bbox=dict(facecolor='wheat'))

ax1.set_ylim(0)

ax1.set_ylabel('Voltage / mV, Time / ns')

ax2.set_ylim(0)

ax2.set_ylabel('Energy / fJ')

fig.suptitle('Distribution')

plt.grid(axis='y')

plt.show()

現在,當我嘗試取消注釋時:

ax1.text(posx,

posy,

f'Average Impulse Interval: Over9000',

bbox=dict(facecolor='wheat'))

Matplotlib引發錯誤:

Exception in Tkinter callback

Traceback (most recent call last):

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axis.py", line 1550, in convert_units

ret = self.converter.convert(x, self.units, self)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\category.py", line 52, in convert

'Missing category information for StrCategoryConverter; '

ValueError: Missing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric data

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__

return self.func(*args)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\backends\_backend_tk.py", line 259, in resize

self.draw()

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 9, in draw

super(FigureCanvasTkAgg, self).draw()

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\backends\backend_agg.py", line 388, in draw

self.figure.draw(self.renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\figure.py", line 1709, in draw

renderer, self, artists, self.suppressComposite)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images

a.draw(renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_base.py", line 2647, in draw

mimage._draw_list_compositing_images(renderer, self, artists)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images

a.draw(renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 670, in draw

bbox, info, descent = textobj._get_layout(renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 276, in _get_layout

key = self.get_prop_tup(renderer=renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 831, in get_prop_tup

x, y = self.get_unitless_position()

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 814, in get_unitless_position

y = float(self.convert_yunits(self._y))

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 192, in convert_yunits

return ax.yaxis.convert_units(y)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axis.py", line 1553, in convert_units

f'units: {x!r}') from e

matplotlib.units.ConversionError: Failed to convert value(s) to axis units: 'T1'

Exception in Tkinter callback

Traceback (most recent call last):

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axis.py", line 1550, in convert_units

ret = self.converter.convert(x, self.units, self)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\category.py", line 52, in convert

'Missing category information for StrCategoryConverter; '

ValueError: Missing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric data

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__

return self.func(*args)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 749, in callit

func(*args)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\backends\_backend_tk.py", line 338, in idle_draw

self.draw()

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 9, in draw

super(FigureCanvasTkAgg, self).draw()

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\backends\backend_agg.py", line 388, in draw

self.figure.draw(self.renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\figure.py", line 1709, in draw

renderer, self, artists, self.suppressComposite)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images

a.draw(renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axes\_base.py", line 2647, in draw

mimage._draw_list_compositing_images(renderer, self, artists)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images

a.draw(renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper

return draw(artist, renderer, *args, **kwargs)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 670, in draw

bbox, info, descent = textobj._get_layout(renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 276, in _get_layout

key = self.get_prop_tup(renderer=renderer)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 831, in get_prop_tup

x, y = self.get_unitless_position()

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\text.py", line 814, in get_unitless_position

y = float(self.convert_yunits(self._y))

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\artist.py", line 192, in convert_yunits

return ax.yaxis.convert_units(y)

File "C:\Users\Artur\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\axis.py", line 1553, in convert_units

f'units: {x!r}') from e

matplotlib.units.ConversionError: Failed to convert value(s) to axis units: 'T1'

我嘗試用整數或浮點數替換'T1' ,但這無濟于事。

不相關似乎我需要在此帖子中添加更多文本。 不要因為我在這里輸入的廢話而分心。

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的python seaborn boxplot_python - 如何将文本框添加到Seaborn Boxplot? - 堆栈内存溢出的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。