DensityPlot[.015 Sin[x + y], {x, 0, Pi}, {y, 0, Pi}, ColorFunction -> "Rainbow",
ImageSize -> 500, Frame -> False, Axes -> True,
AxesLabel -> {"\!\(\*SubscriptBox[\(k\), \(z\)]\)", "\!\(\*SubscriptBox[\(k\), \(x\)]\)"},
PlotLegends -> BarLegend[Automatic, LegendMarkerSize -> 380]]
creates the plot
and Dynamic[MousePosition["Graphics"]]
displays the position of the mouse on the plot, with coordinates between 0 and Pi. However, if I replace BarLegend
in the code above by Placed[BarLegend[Automatic, LegendMarkerSize -> 380], {{1.0, 0.955}, {0.4, 1.0}}]
, the range of coordinates displayed by MousePosition
changes to between 0 and a number or order 0.94. How do I modify my code or otherwise work around this issue? (Observing the maximum values from MousePosition
and using them to rescale the results seems neither robust nor elegant.) By the way, using Placed
also changes the size of the plot.
Placed[BarLegend[Automatic,LegendMarkerSize -> 380], {Scaled@{1.02, 0.97}, Scaled@{0.3, .95}}]
? or{Scaled@{1.03, 0.97}, {0.4, 1.0}}
$\endgroup$Placed
does changeMousePosition["Graphics"]
toMousePosition["GraphicsScaled"]
), played with a few possible work-arounds, and found one that seemed to work:) $\endgroup$Placed[... , After]
and it did work as expected. It's only when specific (non-scaled) coordinates are used that things break. Even the ImageSize behavior changes, accounting for the whole image instead of only the plot part. $\endgroup$