python - 如何在 matplotlib 中创建垂直垂直方向的文本?
解决方案
您可以使用在字符串 ( ) 的每个字符之间'\n'.join(my_string)
插入换行符( )。\n
my_string
如果您还想删除-
符号(这在您的问题中暗示),您可以使用该.replace()
功能删除它们。
考虑以下:
import matplotlib.pyplot as plt
my_string = '2018-08-11'
fig, ax = plt.subplots(1)
ax.text(0.1, 0.5, my_string, va='center')
ax.text(0.3, 0.5, my_string, rotation=90, va='center')
ax.text(0.5, 0.5, '\n'.join(my_string), va='center')
ax.text(0.7, 0.5, '\n'.join(my_string.replace('-', '')), va='center')
plt.show()
推荐阅读
- spring - Spring Cloud Stream:同一个应用程序中的两个不同的Kafka
- java - Android - 如何在谷歌地图上显示 imageView?
- javascript - 现在根据预定数字按升序或降序加载 aria 值
- json - 从服务器获取 JSON 响应数据
- c# - ASP.NET/C# 如何在 PDF 上显示 PNG
- algorithm - 如何确定图 G 是否具有权重为 k 的生成树?
- django - Django表单:在字段旁边而不是在其上方显示标签
- .htaccess - Docker 容器路由
- vb.net - 在 VB.net 中使用 'async' 和 'await' 无需返回
- android - React-native(android) AAPT:错误:找不到资源 android:attr/dialogCornerRadius