FrameTicks-> Automatic in ClickPane causes continuous processor activity

I found that a MatrixPlot in ClickPane causes one of my processor cores in the loop to work about 50% if the FrameTicks -> Automatic option is present. I reduced the code to the following (which does nothing):

 a = ConstantArray[0, {2, 11}]; ClickPane[ Dynamic@ MatrixPlot[a, FrameTicks -> Automatic], # & ] 

enter image description here

Switching to FrameTicks -> None stops kernel activity.

enter image description here

To study the behavior of the processor, I give a Clock loop between None and Automatic every 20 seconds (first remove the above ClickPane):

 ClickPane[ Dynamic@ MatrixPlot[a, FrameTicks -> ft], # & ] Dynamic[ft = {Automatic, None}[[Clock[{1, 2, 1}, 20]]]] 

This gives me the following kind of processor activity:

enter image description here

This is on my Win7-64 / MMA 8.0.1 system.

My questions:

  • Is it reproducible in other systems?
  • Am I doing something wrong or is it a mistake?
  • Why do the naked MatrixPlot[a] (without any FrameTicks settings FrameTicks all) have these odd checkmark options?

enter image description here

+6
source share
3 answers

It seems that the Automatic parameter of the FrameTicks parameter changes the internal variable that can be seen with Dynamic . Apparently (and I mistakenly think) it is not localized. This leads to a complete reevaluation of the Dynamic argument.

The workaround is to add Refresh , which allows you to use TrackedSymbols , so that we can restrict the launch to only the variables of interest to us, in this case the array a and FrameTicks ft :

 ClickPane[ Dynamic@ Refresh[ MatrixPlot[a, FrameTicks -> ft], TrackedSymbols -> {a, ft}], # & ] Dynamic[ft = {Automatic, None}[[Clock[{1, 2, 1}, 20]]]] 

Now my processor status remains zero.

+4
source

Win XP Mma 8.0

enter image description here

Missing peaks correspond to the times when the laptop was hidden by another window. Loss of focus does not stop draining the processor.

+4
source

Also confirmed in Mac OS X 10.6, Mathematica 8.0.1.

At first I thought that this was due to the fact that the kernel should recount where the ticks were, every time the FrameTicks->Automatic option was set.

So, I tried this and got the same result. Similarly for ArrayPlot .

 With[{fta = FrameTicks /. FullForm[MatrixPlot[a, FrameTicks -> Automatic]][[1, 4]]}, ClickPane[ Dynamic@MatrixPlot [a, FrameTicks -> ft], # &] Dynamic[ft = {fta, None}[[Clock[{1, 2, 1}, 20]]]] ] 

But not for this plot - CPU usage barely moved between two states:

 ClickPane[ Dynamic@Plot [Sin[x], {x, 0, 6 Pi}, Frame -> True, FrameTicks -> ft], # &] Dynamic[ft = {Automatic, None}[[Clock[{1, 2, 1}, 20]]]] 

I can only assume that in this bitmap image some FrameTicks inefficiency should be displayed.

In response to your third question, choosing an odd tick does not play in my system.

enter image description here

+2
source

Source: https://habr.com/ru/post/897914/


All Articles