保存绘图注释 [英] Saving plot annotations

查看:23
本文介绍了保存绘图注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天,同时向 .

编辑

Brett Champion 现在将代码移至更合适的问题:如何从 Mathematica 访问 StackOverflow API

解决方案

下面是一种方法,虽然有点难看,但对于小情节注释似乎还可以.

通过绘图工具添加注释后,附加信息与图形一起存储,可以通过例如选择图形括号和使用显示表达式进行检查(Mac 上的 Shift-Command-E).附加信息通常可以通过剪切和粘贴或使用 Cases 来挑选,然后可以使用 Epilog 添加到新的修改图.

例如

绘图[Sin[x], {x, 0, 6 \[Pi]}]

添加一些注释给出以下内容:

将名称 plotgraphic 分配给上面的图像,可以生成一个带有添加注释的新修改图,如下所示(例如)

Labeled[Plot[Sin[x], {x, 0, 8 \[Pi]},结语 ->休息[案例[绘图,_列表][[1]]]],正弦图"]

给予

至少可以说这可能很尴尬,而且该方法无疑可以改进.这也可能与其他人已经在做的事情一致.尽管如此,它还是给出了一个注释以编程方式"存在的情节,而且正如没有人提到 Epilog 一样,我认为它可能值得发布.

Yesterday, while adding some timing plots to the "Optimally picking one element from each list" question I was once more remembered of a mathgroup posting I did a couple of years ago ("Keeping plot annotations after regenerating a plot").

I was happily annotating my plots (manually) when I thought that some axis labels would be nice. Problem is, regenerating the plots with the axis labels in place will destroy your manual annotations.

It appears you can find user additions in a plot named pic here: Rest[pic[[1, 1]]], so if you regenerate the plot as pic2 you can get your annotations back if you use:

Insert[pic2, Rest[pic[[1, 1]]], {1, 1}]

I remember David Park (author of the Presentations package) being vehemently opposed to manual annotations. I have done quite some programmatic labeling myself, but sometimes placing labels under program control is just too difficult, like here (note that I don't like PlotLegends much, especially because some of the colors are close to each other):

It was already too late for my kludge, having thrown away the plot originals, but I wonder what the current state of thinking on this issue is.

  • Are there better ways to do this?
  • How general is this method? Does it work in all plot and chart types?
  • Does it work in all versions? (above 5.2)
  • Any WRI plans to improve handling of user additions in plots?

BTW The trick in my mathgroup posting differed slightly from the one shown above and used in the top-10 plot. The principle is the same, though.


EDIT

I placed the code to make SO data plots like the one above in the Mathematica Toolbag.

EDIT

The code is now moved to the more appropriate question by Brett Champion: How do I access the StackOverflow API from Mathematica

解决方案

One method, which is a bit ugly but seems to work reasonably OK for minor plot annotations, is the following.

After adding annotations via the Drawings tools, the additional info is stored with the graphic and may be inspected by, for example, selecting the graphic bracket and using Show Expression (Shift-Command-E on a Mac). The additional information can usually be picked out by cut-and-paste or using Cases, and then may be added to the new modified plot using Epilog.

For example

Plot[Sin[x], {x, 0, 6 \[Pi]}]

Adding a few annotations gives the following:

Assigning the name plotgraphic to the above image, a new modified plot with added annotations present may be generated as follows (for example)

Labeled[Plot[Sin[x], {x, 0, 8 \[Pi]}, 
  Epilog -> Rest[Cases[plotgraphic, _List][[1]]]], "Sine Plot"]

giving

This can be awkward, to say the least, and the method no doubt can be improved. It is also probably along the lines of what others already do. Nevertheless, it goes give a plot where the annotations are present 'programmatically', and as no-one has mentioned Epilog, I decided it might be worth posting.

这篇关于保存绘图注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆