全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
23270 14
2020-08-04
编辑逼人学stata在编辑要求下修改图形,解锁了stata作图好多option,总结一下





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2020-8-4 22:56:47
1.关于图例

(1)是否显示图例
用 legend(on) legend(off)

(2)设置图例大小

size从小到大分别为vtiny、tiny、vsmall、small、medsmall、medium、medlarge、large、vlarge、huge、vhuge、ehuge

复制代码

(3)设置图例位置


主要有几个options:
    position(clockposstyle) :where legend appears
    ring(ringposstyle) :where legend appears (detail)
    bplacement(compassdirstyle)  :   placement of legend when positioned in the plotregion
    span:"centering" of legend
    at(#)  : allowed with by() only

其中position指定legend 的大概方位,按时钟方向。如 position(10) 表示图例在10点钟方向。ring指定具体位置, ring(0) 表示图例在 plot region,即在图的内部,如图。


微信图片_20200804225515.png

截图参考:
复制代码

(4)设置图例的线条长短

用 symxsize(#)括号里可用数字  

(5)设置部分图例显示部分不显示

比如对照组有很多,没有必要全部表明某个线条是哪个对照组,对照组的线条样式也都一样,这时候图例里只需要出现一个对照组,其他的不显示,打开图形编辑,手动操作选择隐藏(omit)可以实现,但是很难调整位置,不太容易美化图形,这时候最好还是通过命令完成绘图。例如:

复制代码

这里的“1”和“2”应该是绘图的顺序,需要看情况调整。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2021-2-6 18:49:46
2.关于坐标轴

关于坐标轴的命令可以查询

复制代码

然后会出现:

    axis_options are grouped into four classes.


        axis_title_options specify the titles to appear next to the axes.  They also allow you to
            format the title fonts.  See [G-3] axis_title_options.

        axis_label_options specify how the axes should be labeled and ticked.  These options allow you
            to control the placement of major and minor ticks and labels.  axis_label_options also
            allow you to add or to suppress grid lines on your graphs.  See [G-3] axis_label_options.

        axis_scale_options specify how the axes should be scaled -- either logarithmic scaled or
            reverse scaled to run from maximum to minimum.  These options also allow you to change the
            range of the axes and the look of the lines that are the axes, including placement.  See
            [G-3] axis_scale_options.

        axis_choice_options control the specific axis on which a plot appears when there are multiple x
            or y axes.  See [G-3] axis_choice_options.

每一项里都有很多细节可以调整

(1)设置横纵坐标标题的字体、方向和大小等

ytitle、xtitle、 ttitle或者ztitle的option里用以下格式写命令,其中“某个字体的名字”和“坐标轴的标题”用相应的名称替换:

复制代码

至于ytitle、xtitle、 ttitle或者ztitle是什么参见:

复制代码

    axis_title_options         Description
    -----------------------------------------------------
    ytitle(axis_title)         specify y axis title
    xtitle(axis_title)         specify x axis title
    ttitle(axis_title)         specify t (time) axis title
    ztitle(axis_title)         specify contour legend axis title

如果想让坐标轴的标题横过来,需要再加axis_title的option“,orientation(horizontal)”但同时坐标轴的每个字都要分开写,否则一行字都会横过来,相当占地方。调整坐标名称大小的话直接加axis_title的option“size( ) ”,具体字符大小的参数和前面提到的一样。举个例子:

复制代码


(2)设置横纵坐标轴刻度线的位置

可以选(outside|crossing| inside)

复制代码

(3)坐标轴起始值显示为0

需要用到plotregion的option margin
复制代码


(4)坐标轴是否向外延伸

复制代码

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2021-2-6 19:01:26
Tips:

1. 关于option

option意味着要加逗号“,”,有的option还有option的,就继续加逗号和括号,括号要有始有终,stata16里写do文件的时候,把鼠标点到括号的前面或者后面,对应的括号会变红,可以方便检查。

推荐一个b站宝藏up主silencedream,通俗地讲了很多计量的知识,作为入门很适用。




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2023-3-15 11:42:27
感谢分享,学到了很多
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2023-3-31 22:03:31
十分感谢您的分享,学到了很多东西,再次表示感谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群