Message Boards Message Boards

GROUPS:

Avoid problem with dynamic ListStepPlot?

Posted 1 year ago
1184 Views
|
9 Replies
|
1 Total Likes
|

Dear Community,

I'm trying to construct a dynamic ListStepPlot via locators. The three locators (pt1, pt2, pt3) are confined inside a polygon. Upon running the code however the ListStepPlot constructed from the dynamic points does not show up. Could someone pls. have a look and help? The notebook is attached.

Tx in advance,

best regards Andras

Attachments:
9 Replies

You cannot put a ListStepPlot that way inside Graphics. You can combine Graphics with ListStepPlot with Show or Inset.

Dear Gianluca,

Could you pls. check my updated notebook BD3PListStepPlot_Show.nb above? I could not manage to make LisStepPlot dynamic.

Tx in advance, best regards

Andras

Dear Gianluca,

Tx for the tip. Show works and the ListStepPlot shows up correctly initially, but it is still not dynamic and it does not move as I drag the Locators. How could I make it dynamic? (Notebook attached)

Tx for the help in advance, best regards Andras

Attachments:

The ListStepPlot may overshadow the Locators that are in the same positions. Try writing ListStepPlot before the Graphics, so that the Locators come on top of the plot, with a Dynamic before Show.

Dear Gianluca,

Did not work either. No problem, I'll try another solution, I gues I'll write a function for that.

BTW may I have another question? How could I add a flying annotation to a Locator? I.e. a label (e.g. "P1"), which moves together with the Locator upon draging?

Tx in advance best regards

Andras

Try

Graphics[Dynamic@ First@ ListStepPlot[{pt1, pt2, pt3}]]

@Michael

Thank you very much

best regards

Andras

This way it seems to work:

DynamicModule[{pt1 = {0.8, qgHSZ[0.2] }, pt2 = {0.6, qgHSZ[0.5] },
  pt3 = {0.3, qgHSZ[0.25] }, from = .2 , x},
 Dynamic@Show[
   ListStepPlot[ {pt1 , pt2 , pt3} , Axes -> False],
   Graphics[{Line[{{from , pt1[[2]]}, pt1}], 
     LightBlue , {Opacity[0.01], EdgeForm[Thin], poly},
     l1 = 
      Locator[Dynamic[
        pt1, (pt1 = RegionNearest[poly, #]; 
          from = If[pt1[[2]] > 4.55, 
            x /. NSolve[qgHSZ[x] == pt1[[2]], x][[1]], 0.]) & ]],
      l2 = Locator[Dynamic[pt2, (pt2 = RegionNearest[poly, #]) &]],
      l3 = Locator[Dynamic[pt3, (pt3 = RegionNearest[poly, #]) &]],
     Red, Text["P1", pt1, 2 {1, 1}]}],
   Axes -> True, AxesOrigin -> {0, 0}, AspectRatio -> 1 , 
   PlotRange -> CoordinateBounds[poly], 
   PlotRangePadding -> Scaled[.05], Ticks -> Automatic]]  

Dear Gianluca,

Works perfect, thank you very much, great help to my work :-)

best regards

Andras

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract