保存绘图注释
昨天,在向 “最优选择一个元素”添加一些时序图时从每个列表中“问题我再次想起几年前我发表的数学组帖子("重新生成绘图后保留绘图注释")。
当我认为一些轴标签会很好时,我很高兴地(手动)注释我的图。问题是,重新生成带有轴标签的绘图会破坏您的手动注释。
看来您可以在此处名为 pic 的绘图中找到用户添加内容:Rest[pic[[1, 1]]]
,因此,如果您将绘图重新生成为 pic2,则可以在使用时取回注释:
Insert[pic2, Rest[pic[[1, 1]]], {1, 1}]
我记得 David Park(演示包的作者)强烈反对手动注释。我自己已经做了一些程序化标签,但有时将标签置于程序控制下太困难了,就像这里一样(请注意,我不太喜欢 PlotLegends
,特别是因为某些颜色接近彼此):
对于我的拼凑来说已经太晚了,已经扔掉了情节原件,但我想知道目前对这个问题的想法是什么。
- 有更好的方法来做到这一点吗?
- 这种方法有多通用?它适用于所有绘图和图表类型吗?
- 它适用于所有版本吗? (上文 5.2)
- WRI 是否计划改进对图中用户添加的处理?
顺便说一句,我的 mathgroup 帖子中的技巧与上面显示的并在前 10 名图中使用的技巧略有不同。不过原理是一样的。
编辑
我放置了代码来制作像上面那样的数据图 Mathematica 工具包。
编辑
代码现在已移至 Brett Champion 更合适的问题:How do I access the StackOverflow API from数学
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我同意 David Park 的观点,即以编程方式添加注释更为优越。它也可能会更加强大,并且可以与 Mathematica 的未来版本一起使用。我真的很希望看到绘图工具调色板有所改进,并且希望看到手动添加的多个注释更清晰地出现在生成的
Graphics
对象中。如果有像AddedAnnotation
之类的惰性Head
或类似的东西,那么您可以通过编程方式找到所有这些编辑。事实上,我发现自己正在挖掘
InputForm< /code> 图像,我不确定您的
Rest[pic[[1, 1]]]
是否始终有效,特别是在未来的版本中。Personally, I agree with David Park that programmatic addition of annotation is superior. It's also likely to be more robust and work with future editions of Mathematica. I'd really like to see the drawing tools palette improved a bit and I'd like to see multiple annotations added by hand appear in the resulting
Graphics
object more clearly. If there were an inertHead
likeAddedAnnotation
or some such, then you could find all these edits programmatically viaAs it is, I find myself digging through the
InputForm
of the image and I'm not certain that yourRest[pic[[1, 1]]]
is always going to work, particularly in future versions.一种方法有点难看,但对于次要的情节注释似乎相当有效,如下所示。
通过
绘图工具
添加注释后,附加信息将与图形一起存储,并且可以通过例如选择图形括号并使用显示表达式
(Shift- Mac 上的 Command-E)。通常可以通过剪切和粘贴或使用 Cases 来挑选附加信息,然后可以使用 Epilog 添加到新的修改图中。例如,
添加一些注释如下:
将名称
plotgraphic
分配给对于上面的图像,可以生成带有添加注释的新修改图,如下所示(例如)给出
至少可以说,这可能会很尴尬,而且该方法无疑可以改进。它也可能遵循其他人已经做的事情。尽管如此,它还是给出了一个图,其中注释以“编程方式”存在,并且由于没有人提到
Epilog
,我认为它可能值得发布。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 usingShow Expression
(Shift-Command-E on a Mac). The additional information can usually be picked out by cut-and-paste or usingCases
, and then may be added to the new modified plot usingEpilog
.For example
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)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.