我试图在框图中插入一个文本框,但是出了点问题。 让我们先绘制箱线图:

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? - 堆栈内存溢出相关推荐

  1. python sobel滤波_python - 如何提高sobel边缘检测器的效率 - 堆栈内存溢出

    即使您正在构建自己的库,您也绝对应该使用库进行卷积,它们将在后端用C或Fortran进行结果运算,这将大大加快速度. 但是,如果您愿意,可以自己做,使用线性可分离滤波器. 这是想法: 图片: 1 2 ...

  2. python tkinter 背景色改变不了_python - Tkinter背景颜色问题 - 堆栈内存溢出

    我有一个脚本,其中包含Tkinter模块,我想每隔3分钟更改一次背景颜色,例如绿色3分钟,然后橙色,然后红色. 我有显示绿色的代码,但无法更改它. 当我在代码中创建函数时,会遇到一些不同的错误,包括& ...

  3. android 添加意图,c# - Xamarin.Android:如何为每个通知添加唯一的意图 - 堆栈内存溢出...

    我将Intent添加到Android.Support.V4.App.NotificationCompat.Builder但Extras没有传递到OnNewIntent的重写中,并且似乎该参数始终是相同 ...

  4. python多个摄像头_python - 使用python和OpenCV与VideoCapture洞察多个网络摄像头捕获 - 堆栈内存溢出...

    我正在尝试同时(或几乎同时)从多个网络摄像头捕获图像. 我一直在玩OpenCV ,使用VideoCapture和python编程. 但有一些困惑,希望有人可以帮助解释事情...... 首先,我尝试了V ...

  5. python堆栈反向输出列表_python - IPython:将Python脚本的输出重定向到文件(如bash) - 堆栈内存溢出...

    IPython有自己的上下文管理器来捕获stdout / err ,但它没有重定向到文件,它重定向到一个对象: from IPython.utils import io with io.capture ...

  6. tkinter向文本框里加内容_给tkinter文本框添加右键菜单

    给tkinter文本框添加右键菜单 需求:直接右键点击使用tkinter创建的文本框是不会弹出菜单的.我们需要实现右键点击tkinter框架下的Entry对象.Text对象后弹出右键菜单可复制.粘贴和 ...

  7. WinForm -- 为TextBox文本框添加鼠标右键菜单

    WinForm -- 为TextBox文本框添加鼠标右键菜单 1. 新建一个WinForm项目,放置一个TextBox控件 2. 从工具箱拖进来一个ContextMenuStrip 3. 将TextB ...

  8. 滚动条的值如何赋值_如何给Word文本框添加滚动条?史上最详细步骤

    在工作中我们经常需要使用Microsoft Word来进行编辑文件等,而Microsoft Word也总是能给我们许多的惊喜,因为它总能帮助我们去解决许多工作上的问题.当有些小伙伴不再是局限于仅仅使用 ...

  9. 给文本框添加模糊搜索功能(“我记录”MVC框架下实现)

    步骤: 1.在文本框中输入内容时,触发keyup事件: 2.在keyup事件的处理方法中,通过Ajax调用控制器的方法: 3.在控制器方法中,搜索满足条件的数据,这里分页获取数据,且只取第一页的数据, ...

最新文章

  1. 1027 Colors in Mars
  2. python培训中心-吴中区Python培训中心
  3. 数据增删改查之三层架构(理解三层续)
  4. linux 获取内核线程数,如何从命令行获取Linux中的CPU /内核数量?
  5. isotope == parallax 例子
  6. 通俗的说下浏览器的渲染过程
  7. python比较时间的最大值_时间戳的最大值
  8. NLP领域中更有效的迁移学习方法
  9. [UE4] Sequence 的某一条分支执行 delay 之后会继续执行下一条分支而不是停留在该分支
  10. 漫步微积分三十——定积分的性质
  11. 金属零件图像数据集_如何使用包装零件来开发易于维护的数据仓库解决方案
  12. Redis学习笔记(二) Redis 数据类型
  13. 前端开发面试题收集 JS
  14. Notes on Operating System
  15. java 实例化是什么及五种实例化方法
  16. kali linux 入侵教程,kali linux 入侵wordpress! wpscan工具使用方法!
  17. postman接口批量测试
  18. error LNK1120: 2个无法解析的外部命令:vtkRenderingOpenGL_AutoInit(Construct、Destruct),该函数在......中被引用
  19. matlab圈和叉,画圈圈和画叉叉的区别
  20. 交通违章 处罚[转]

热门文章

  1. 多个 VUE 前端工程部署设置、nginx 代理配置
  2. 【Linux】Linux中常用操作命令
  3. Silverlight Blend动画设计系列八:拖放(Drag-Drop)操作与拖放行为(DragBehavior)
  4. day8-异常处理与网络编程
  5. 微信获取token -1000
  6. HTML5 SVG
  7. 表单验证的初步实现和省市级联
  8. navicat 的查询功能
  9. FLEXAIR 界面展示。
  10. 如何保证MongoDB的安全性? 1