如何防止具有固定精度的pgfplots中四舍五入和重复的刻度标签?

Sören Schulze 06/06/2015. 1 answers, 644 views
tikz-pgf pgfplots

我有一个情节,其y轴是线性的,具有固定的精度并且没有缩放。

  \ {的DocumentClass独立}  \ usepackage {pgfplots}  \ pgfplotsset {COMPAT = 1.11}   \ {开始}文件  \ {开始} tikzpicture    \开始{轴} [域= -0.1:0.1,                 / pgf / number format / precision = 3}]      \ addplot + {x ^ 3};    \ {端轴}  \ {端} tikzpicture  \ {端文档} 

f(x)= x ^ 3

y tick标签的表现力很小,因为pgf在中间圆整为0.0005至0.001,产生了矛盾标签。 我真的不想提高精度(页面上的空间限制),所以显然最好的解决方案是删除中间的“( - )0.001”滴答。 有没有一个pgfplots选项来实现这一点? 一个说“不要放蜱,使标签变圆”,“标签之间的最小差异应该是0.001”或相似。

我的文档中有100个类似的图表来自数据,这些图表可能会发生变化,所以手动指定y记号不是首选。

1 Comments
Sören Schulze 06/06/2015
我宁愿他们不要缩放,因为100个地块,每个都有不同的缩放比例,会令人困惑。 但是,是的,也许增加一些(固定?)缩放是最好的解决方案,如果我想要做的是不可能的。

1 Answers


percusse 06/06/2015.

一种可能性是比较修剪后的版本是否与原始的订单号不同。 但这是一个相当普遍的规范,所以如果你的其他99个地块有不同的奇怪间隔,我不认为这将是万无一失的

\documentclass{standalone}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[domain=-0.1:0.1,
               yticklabel style={scaled ticks=false,
                                 /pgf/number format/fixed,
                                 /pgf/number format/precision=3},
  yticklabel={%
    \pgfmathprintnumberto[verbatim,fixed,precision=3]{\tick}\possiblytrimmedtick%
    \pgfmathparse{\possiblytrimmedtick == \tick ? int(1):int(0)}%
    \ifnum\pgfmathresult>0\relax$\tick$\else\fi%
 }
]
    \addplot+ { x^3 };
  \end{axis}
\end{tikzpicture}
\end{document} 

在这里输入图像描述

1 comments
Sören Schulze 06/06/2015
抑制蜱本身(不仅仅是标签)是理想的,但除此之外,它对我来说效果很好。 编辑:我想我会像这样离开它。

HighResolutionMusic.com - Download Hi-Res Songs

1 (G)I-DLE

POP/STARS flac

(G)I-DLE. 2018. Writer: Riot Music Team;Harloe.
2 Ariana Grande

​Thank U, Next flac

Ariana Grande. 2018. Writer: Crazy Mike;Scootie;Victoria Monét;Tayla Parx;TBHits;Ariana Grande.
3 Clean Bandit

Baby flac

Clean Bandit. 2018. Writer: Jack Patterson;Kamille;Jason Evigan;Matthew Knott;Marina;Luis Fonsi.
4 Imagine Dragons

Bad Liar flac

Imagine Dragons. 2018. Writer: Jorgen Odegard;Daniel Platzman;Ben McKee;Wayne Sermon;Aja Volkman;Dan Reynolds.
5 Halsey

Without Me flac

Halsey. 2018. Writer: Halsey;Delacey;Louis Bell;Amy Allen;Justin Timberlake;Timbaland;Scott Storch.
6 BTS

Waste It On Me flac

BTS. 2018. Writer: Steve Aoki;Jeff Halavacs;Ryan Ogren;Michael Gazzo;Nate Cyphert;Sean Foreman;RM.
7 Nicki Minaj

No Candle No Light flac

Nicki Minaj. 2018. Writer: Denisia “Blu June” Andrews;Kathryn Ostenberg;Brittany "Chi" Coney;Brian Lee;TJ Routon;Tushar Apte;ZAYN;Nicki Minaj.
8 Backstreet Boys

Chances flac

Backstreet Boys. 2018.
9 BlackPink

Kiss And Make Up flac

BlackPink. 2018. Writer: Soke;Kny Factory;Billboard;Chelcee Grimes;Teddy Park;Marc Vincent;Dua Lipa.
10 Little Mix

The Cure flac

Little Mix. 2018. Writer: Pete Kelleher;Camille Purcell;Tom Barnes;Ben Kohn.
11 Fitz And The Tantrums

HandClap flac

Fitz And The Tantrums. 2017. Writer: Fitz And The Tantrums;Eric Frederic;Sam Hollander.
12 Diplo

Close To Me flac

Diplo. 2018. Writer: Ellie Goulding;Savan Kotecha;Peter Svensson;Ilya;Swae Lee;Diplo.
13 The Chainsmokers

Beach House flac

The Chainsmokers. 2018. Writer: Andrew Taggart.
14 Bradley Cooper

Always Remember Us This Way flac

Bradley Cooper. 2018. Writer: Lady Gaga;Dave Cobb.
15 Kelly Clarkson

Never Enough flac

Kelly Clarkson. 2018. Writer: Benj Pasek;Justin Paul.
16 Lady Gaga

I'll Never Love Again flac

Lady Gaga. 2018. Writer: Benjamin Rice;Lady Gaga.
17 Frida Sundemo

Apologize flac

Frida Sundemo. 2018.
18 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
19 Imagine Dragons

Machine flac

Imagine Dragons. 2018. Writer: Wayne Sermon;Daniel Platzman;Dan Reynolds;Ben McKee;Alex Da Kid.
20 Billie Eilish

When The Party's Over flac

Billie Eilish. 2018. Writer: Billie Eilish;FINNEAS.

Related questions

Hot questions

Language

Popular Tags