6/21/2023 0 Comments Matplotlib python rename x labelIt's been a while since this question was asked. In that case, look into annotate, instead. Often, what you actually want to do is just annotate a certain position. Hopefully that makes it slighly more clear as to why changing an individual tick label is a bit convoluted. This is what set_*ticklabels or ax.*t_ticklabels does. However, if the Locators and Formatters are set to be static ( FixedLocator and FixedFormatter, respectively), then the tick labels stay the same. By default, it's re-set by the axis's Locator and Formatter every time the plot is drawn. Therefore, you can't just set the text of a given tick label. The assumption is that you'll want to interact with the plot, and so the bounds of the plot, ticks, ticklabels, etc will be dynamically changing. Matplotlib deliberately avoids doing "static" positioning of ticks, etc, unless it's explicitly told to. To understand the reason why you need to jump through so many hoops, you need to understand a bit more about how matplotlib is structured. # We need to draw the canvas, otherwise the labels won't be positioned and Normally, you'd do something along these lines: import matplotlib.pyplot as plt It may be an unintended change, or it may not be. If you're working from the current github master, this won't work. a boxplot), this will not work with any version of matplotlib newer than 1.1.0. Caveat: Unless the ticklabels are already set to a string (as is usually the case in e.g.
0 Comments
Leave a Reply. |