设置不同的刻度长度 [英] Setting different tick lengths

查看:149
本文介绍了设置不同的刻度长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图,其中我希望沿x轴有多个刻度线,但是只有一些刻度线会与之相关联的刻度线标签.但是,我希望带有标签的标签的刻度线比没有标签的标签的刻度线长.

I have a plot in which I'd like many ticks along the x-axis, yet only some of the ticks will have tick labels associated with them. However, I'd like the tick marks for those that have labels to be longer than those that don't.

我知道您可以打开x轴MinorTicks,但这不能让您控制这些刻度的实际位置.例如,如果x轴表示天,我希望每7天打勾,但每28天打一次标签.

I know that you can turn the x-axis MinorTicks on, but that won't let you control where those ticks are actually located. For example, if the x-axis signifies days, I want tick marks every 7 days but labels every 28 days.

此外,设置XTickLength仅允许您设置每个刻度线的长度,而不能有选择地设置

Moreover, setting the XTickLength only lets you set the length for every tick mark, and not selectively.

控制刻度长度的最佳方法是什么,同时允许您确切指定刻度的位置?

What is the best way to control the tick lengths while allowing you to specify exactly where the ticks should be?

推荐答案

yuk 关于刻度标签的类似问题上//://stackoverflow.com/a/9171004/395857>此SO答案 a>:

As said by yuk in this SO answer on a similar question about tick labels:

刻度标签不是单独的对象.它们属于轴,其属性由轴确定.

Tick labels are not individual objects. They belong to axes and their properties determined by axes.

您可以做的是删除刻度线标签,然后将其替换为文本. 对象.在这种情况下,您可以控制文本属性.

What you can do is to remove tick labels and replace them with text objects. In this case you can control the text properties.

我想刻度线也一样,但这可能更棘手.

I guess the same applies to tick marks, but it is probably trickier.

另一种解决方案可以是将第二条轴叠加在原始轴上,如建议 ://stackoverflow.com/users/471614/> bdecaf .

Another solution could be to overlay your original axis with a second one, as suggested by bdecaf.

这篇关于设置不同的刻度长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆