相关疑难解决方法(0)

用pyplot绘制一个圆圈

令人惊讶的是,我没有找到关于如何使用matplotlib.pyplot绘制圆形的直接描述(请不要使用pylab)作为输入中心(x,y)和半径r.我试过这个的一些变种:

import matplotlib.pyplot as plt
circle=plt.Circle((0,0),2)
# here must be something like circle.plot() or not?
plt.show()
Run Code Online (Sandbox Code Playgroud)

......但仍然无法正常工作.

python matplotlib

134
推荐指数
7
解决办法
28万
查看次数

matplotlib:在绘图中添加圆圈

如何在matplotlib中将一个小圆圈或点添加到countour图中?

python matplotlib

23
推荐指数
1
解决办法
4万
查看次数

Matplotlib,添加多行文本.添加可以跟随曲线的文本

我已经将文本添加到绘图中,在每行中编码,然后调整它看起来像样,增加或减少宽度,或更改位置.但是,有没有办法让Python知道你想要文本的位置以及你想要它的设置方式?然后我可以添加文本,Python将计算出细节.

例如,看看下面的图片:

在此输入图像描述

在图中,我在左上角有3行文字,在图的线上有一行.

我不得不调整3条线以获得合适的间距.这不是一项艰巨的任务,但如果我能说这里是文本,这里就是位置,那将很容易,然后Python以适当的间距堆叠它.

对于单独的线路,我不得不进行调整,因此它不在线上并降低线路.对于这种情况,有可能告诉python我想在情节上方的文字和80%下线?

我习惯于LaTeX在没有硬编码坐标的情况下进行调整的地方.优点是

(1) if I want to change the location, I can change the percentage shift and not the coordinate.

(2) if the line is angled, the text will adjust to the line.
Run Code Online (Sandbox Code Playgroud)

(2)的优点是我试图将文字放在图中顶部向上倾斜的文本上.

可以这样做,还是我要求多少?如果是这样,我该怎么做?

以下是实现该图的代码:

import numpy as np
import pylab

r1 = 1  #  AU Earth                                                                 
r2 = 1.524  #  AU Mars                                                              
deltanu = 75 * np.pi / 180  #  angle in radians                                     
mu = 38.86984154054163

c = np.sqrt(r1 ** 2 + …
Run Code Online (Sandbox Code Playgroud)

python curve text matplotlib

5
推荐指数
1
解决办法
8323
查看次数

标签 统计

matplotlib ×3

python ×3

curve ×1

text ×1