小编Giu*_*ora的帖子

创建一个 matplotlib mpatches ,其中带有双色矩形作为图形图例

我需要为 matplotlib 图中的图例创建一个补丁,其句柄框是一个具有两种颜色的矩形。像这样的东西,是我用油漆处理、切割和着色制作的:在此输入图像描述

你能告诉我如何以及从哪里开始吗?谢谢。

python matplotlib python-3.x

3
推荐指数
1
解决办法
1846
查看次数

从python脚本导出tex文件:"TypeError:需要浮点数"

这是要在tex文件中写入的内容:

content=r'''\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs} % for much better looking tables
\usepackage{multirow}
\usepackage{caption}
\captionsetup{labelformat=empty} 

\begin{document}
\begin{table}[htbp]\caption{Common Prediction}
\centering
\input{common%(index)s}
\end{table}     

\end{document}
'''
Run Code Online (Sandbox Code Playgroud)

我想用积分值替换'index'.我写的时候:

with open(directoryPath + os.sep +'commonTables3.tex','w') as f:
    f.write(content%({'index':str(3)}))
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

f.write(content%({'index':str(3)}))
TypeError: a float is required
Run Code Online (Sandbox Code Playgroud)

我不明白我的错误在哪里.我尝试在'%(index)d'中更改'%(index)s'('index'中的'index':str(3):3)但我仍然有相同的错误.谢谢

python string latex python-3.x

2
推荐指数
1
解决办法
50
查看次数

标签 统计

python ×2

python-3.x ×2

latex ×1

matplotlib ×1

string ×1