Message Boards Message Boards

Avoid problem with dynamic ListStepPlot?

GROUPS:

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:
POSTED BY: Andras Gilicz
Answer
22 days ago

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

POSTED BY: Gianluca Gorni
Answer
21 days ago

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

POSTED BY: Andras Gilicz
Answer
21 days ago

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:
POSTED BY: Andras Gilicz
Answer
21 days ago

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.

POSTED BY: Gianluca Gorni
Answer
21 days ago

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

POSTED BY: Andras Gilicz
Answer
20 days ago

Try

Graphics[Dynamic@ First@ ListStepPlot[{pt1, pt2, pt3}]]
POSTED BY: Michael Rogers
Answer
20 days ago

@Michael

Thank you very much

best regards

Andras

POSTED BY: Andras Gilicz
Answer
20 days ago

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]]  
POSTED BY: Gianluca Gorni
Answer
20 days ago

Dear Gianluca,

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

best regards

Andras

POSTED BY: Andras Gilicz
Answer
20 days ago

Group Abstract Group Abstract