[英]How to format chart in Roassal 3?
I made a chart following the examples in the documentation.我按照文档中的示例制作了一个图表。 I find the title and x/y labels too close to the plot itself, and the tick labels too small.
我发现标题和 x/y 标签太接近 plot 本身,而且刻度标签太小。 How do I format them?
如何格式化它们?
x := -3.14 to: 3.14 count: 100.
y := x sin.
c := RSChart new.
p := RSLinePlot new x: x y: y.
c addPlot: p.
c title: 'Sine function'.
c xlabel: 'X axis'.
c ylabel: 'Y axis'.
c addDecoration: RSHorizontalTick new.
c addDecoration: RSVerticalTick new.
c open
The way the graph is constructed it uses the default offset of 5
for X axis
and -5
for Y axis
in the initialize
of RSXLabelDecoration
or RSYLabelDecoration
respectively.图形的构建方式分别在
RSXLabelDecoration
或RSYLabelDecoration
的initialize
中使用默认偏移量5
表示X axis
和-5
表示Y axis
。
To move the titles around you have to create them yourself instead of using xlabel
or ylabel
.要移动标题,您必须自己创建它们,而不是使用
xlabel
或ylabel
。
You whould have to replace these two lines of code:您必须替换这两行代码:
c xlabel: 'X axis'.
c ylabel: 'Y axis'.
with:和:
xAxisDecoration := c addDecoration: (RSXLabelDecoration new title: 'X axis'; offset: 15).
yAxisDecoration := c addDecoration: (RSYLabelDecoration new title: 'Y axis'; offset: -15).
The result:结果:
Edit - forgot about the tick labels编辑 - 忘记了刻度标签
To adjust the font size you need to add a message fontSize
when creating a RSHorizontal(Vertical)Tick
要调整字体大小,您需要在创建
RSHorizontal(Vertical)Tick
时添加消息fontSize
The affected code would look like this:受影响的代码如下所示:
c addDecoration: (RSHorizontalTick new fontSize: 10).
c addDecoration: (RSVerticalTick new fontSize: 10).
Producing this result:产生这个结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.