PlotLegends 使 Manipulate[] 图形缓慢爬行 [英] PlotLegends makes Manipulate[] ing graphs slow to a crawl

查看:19
本文介绍了PlotLegends 使 Manipulate[] 图形缓慢爬行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个简短的程序来使用 Manipulate 显示具有不同参数的相同函数的三个图.我想用参数的值标记每个函数.我的出发点是让一个传奇人物出现.向绘图中添加 PlotLegend 会导致 Mathematica 变得非常缓慢.

I have a short program set up to display three plots of the same function with different parameters using Manipulate. I'd like to label each function with the value of the parameter. My starting point was to just get a legend to show up at all. Adding a PlotLegend to the plot causes Mathematica to become unusably slow.

我的代码是:

Needs["PlotLegends`"]
Manipulate[

 UemaxOverUe = ((VA/Vphs)^2 (2 p - 1) + 1 - Ves0/Vphs - 2)/((VA/Vphs)^2 - (1 - Ves0/Vphs));

 UemaxOverUe2 = ((VA/Vphs)^2 (2 p - 1) + 1 - Ves02/Vphs - 2)/((VA/Vphs)^2 - (1 - Ves02/Vphs));

 UemaxOverUe3 = ((VA/Vphs)^2 (2 p - 1) + 1 - Ves03/Vphs - 2)/((VA/Vphs)^2 - (1 - Ves03/Vphs));

 ListPlot[{
  Table[{Vphs/VA, 1/UemaxOverUe}, {Vphs, .001 VA, VA, .01 VA}], 
  Table[{Vphs/VA, 1/UemaxOverUe2}, {Vphs, .001 VA, VA, .01 VA}], 
  Table[{Vphs/VA, 1/UemaxOverUe3}, {Vphs, .001 VA, VA, .01 VA}]}, 
  AxesLabel -> {"Vphs/VA", "Ne/NeMax"}, Joined -> True(*,
  PlotLegend->{"Blah","Blarg","Word"}*)],

 {{p, 1}, 0, 5},
 {{Ves0, -2 VA}, -10 VA, 10 VA, .1 VA},
 {{Ves02, -2 VA}, -10 VA, 10 VA, .1 VA},
 {{Ves03, -2 VA}, -10 VA, 10 VA, .1 VA}
]

取消注释 PlotLegend 应该会重现问题.

Uncommenting the PlotLegend should recreate the problem.

我的问题是:为什么会发生这种情况?
什么是好的解决方案或解决方法?

My questions are: Why does this happen?
What is a good solution, or workaround?

推荐答案

问题似乎是 PlotLegend 速度很慢.它与 Manipulate 没有任何关系.在我的电脑上,ListPlot 在没有图例的情况下需要 0.013 秒,如果添加了图例,则需要 0.43 秒.

The problem seems to be that PlotLegend is just slow. It hasn't got anything to do with Manipulate. On my PC The ListPlot takes 0.013 s without a legend and 0.43 second if a legend is added.

作为一种解决方法,您可以使用

As a workaround you could use

ControlActive[{}, PlotLegend -> {"Blah", "Blarg", "Word"}]]

而不仅仅是 PlotLegend 仅在您不移动滑块时才显示图例.

instead of just the PlotLegend to show the legend only when you're not moving the sliders.

这篇关于PlotLegends 使 Manipulate[] 图形缓慢爬行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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