我想知道是否可以在轴说明中使用下标。我有以下代码
XYItemRenderer lineYY = new StandardXYItemRenderer();
lineYY.setSeriesPaint(0, Color.BLUE);
lineYY.setSeriesVisibleInLegend(0,false);
final NumberAxis yaxY = new NumberAxis("ax [m/s²]");
yaxY.setRange(-11, 11);
yaxY.setAutoRangeIncludesZero(false);
XYPlot plotYY = new XYPlot(datasetY,null,yaxY, lineYY);
plotYY.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
是否可以在字符串“ a x [m /s²]”中对x下标?下标为例如X₉
使用此处显示的方法,可以AttributedString
为所需的轴标签指定一个。给定一个NumberAxis
named domain
,下面的示例使用TextAttribute
值更改某些字符的SIZE
和WEIGHT
,在第二个字符下标并在指数上标。
String s = "ax [m/s2]";
AttributedString as = new AttributedString(s);
as.addAttribute(TextAttribute.SIZE, 24, 0, 2);
as.addAttribute(TextAttribute.SIZE, 16, 3, 9);
as.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, 0, 2);
as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1, 2);
as.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER, 7, 8);
domain.setAttributedLabel(as);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句