如何在固定位置(matplotlib)上设置刻度线

编程入门 行业动态 更新时间:2024-10-25 02:26:37
本文介绍了如何在固定位置(matplotlib)上设置刻度线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以使用matplotlib帮助我将刻度线设置在固定位置吗?我已尝试使用本教程介绍的FixedPosition:

Can anyone help me set the ticks on a fixed position using matplotlib? I've tried using FixedPosition as this tutorial describes:

ax = pl.gca() ax.xaxis.set_major_locator(eval(locator))

scipy-lectures.github.io /intro/matplotlib/matplotlib.html#figures-subplots-axes-and-ticks

但是当我尝试运行时,它告诉我set_major_locator方法不存在.

But when I try to run, it tells me that set_major_locator method does not exist.

一个简单的示例将非常有用.

A simple example would be very useful.

谢谢.

推荐答案

只需使用ax.set_xticks(positions)或ax.set_yticks(positions).

例如:

import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.set_xticks([0.15, 0.68, 0.97]) ax.set_yticks([0.2, 0.55, 0.76]) plt.show()

更多推荐

如何在固定位置(matplotlib)上设置刻度线

本文发布于:2023-10-08 02:51:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1471295.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:刻度   位置   如何在   matplotlib

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!