python - matplotlib 没有绘制整条曲线
问题描述
我正在绘制几条曲线,但不知何故并没有继续整个情节。我绘制到https://www.desmos.com/calculator?lang=es
[![import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
np.seterr(divide='ignore', invalid='ignore')
# Construct lines
# x > 0
x = np.linspace(1, 20, 2000)
# C1
y1 = np.sqrt(560000/(np.pi*x))
#C2
y2= 10*x/4
#C3
plt.axvline(x=35, color='r')
# Add lines to complete first 2 constraints
# plt.axvline(y=35, color='r')
# Make plot
plt.plot(x, y1, label=r'$\frac{\pi}{4} {x_{1}} {x_{2}}^2 \leq 140000$')
plt.plot(x, y2, label=r'$10 x_{1} - 4 x_{2}\leq 0$')
# plt.xlim((0, 40))
# plt.ylim((0, 1000))
plt.xlabel(r'$x_1$')
plt.ylabel(r'$x_2$')
#plot legend
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)][1]][1]
解决方案
我刚刚发现错误,x = np.linspace(1, 20, 2000)
需要调整最大限制x = np.linspace(1, 100, 2000)
推荐阅读
- php - 如何在 Laravel 中插入具有多个不同列的多行
- javascript - Discord bot 开发的 SQL 语法问题 (mySQL 8.0)
- android - 条件片段和导航重用
- ms-access - WScript.Shell 运行时错误 - IwshShell3 失败
- java - 从 Word 文档中读取 .docx 格式的数据作为每个字段,并用 Java 将其保存在数据库中
- pip - Conda 版本 pip install -r requirements.txt --target ./lib
- c# - 是否可以在检查器窗口中锁定或覆盖游戏对象缩放属性坐标?
- php - Silverstripe 4 SiteConfig 徽标图像未显示在模板中
- python-3.x - 如何调试“'module' object is not callable”的错误?
- linq - CosmosDB - 子文档删除选择 - LINQ 查询