python - 就 ax.spines 而言,set_position('center') 和 set_position('zero') 有什么区别
问题描述
我正在尝试绘制这样的情节。
我研究了来自matplotlib的示例。
我所知道的是
左脊柱可以在笛卡尔坐标平面中扮演 y 轴的角色。
底部脊柱可以在笛卡尔坐标平面中扮演 x 轴的角色。
set_position()
可以移动刺。
我的问题是将脊椎(例如,“左”)放在“中心”和“零”之间有什么区别。
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
x = np.linspace(-np.pi, np.pi, 100)
y = 2 * np.sin(x)
ax = fig.add_subplot(2, 2, 1)
ax.set_title('centered spines')
ax.plot(x, y)
ax.spines['left'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax = fig.add_subplot(2, 2, 2)
ax.set_title('zeroed spines')
ax.plot(x, y)
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.show()
解决方案
推荐阅读
- c# - 进程类启动泄漏内存
- c# - “使用 Visual Studio 调试 lambda 表达式”不再起作用?
- android - SIMpleDateFormat 使用 GMT + 6.5 返回错误值
- swift4 - 是否可以使用 ML Kit 以纵向模式扫描条码?
- ruby - 使用 Ruby 为 iTunes Connect API 生成 JWT
- c++ - operator< 给出 operator __surrogate_func 错误
- gradle - 如何有条件地接受 Kotlin DSL 中的 Gradle 构建扫描插件服务条款?
- sql - 如何获得多个 SUM 语句的总数
- java - 如何在我的 java 应用程序中连接到 mongo db?
- c# - 在 ASP.net 核心应用程序的强类型配置类中使用 System.Uri