SelectionType, 'alt' ) % right-click if isa (hitPrimitive, '.Text' ) % labelĭisplayTextContextMenu (hitPrimitive, hitPoint ) elseif isa (hitPrimitive, '.LineStrip' ) % contour lineĭisplayLineContextMenu (hitPrimitive, hitPoint ) elseif isa (hitPrimitive, '.TriangleStrip' ) % contour fillĭisplayFillContextMenu (hitPrimitive, hitPoint ) else. Point % undocumented property => returns pixels from figure's bottom-left corner if strcmpi (hFig. HitPrimitive % undocumented property => returns a Text or LineStrip object HitObject % undocumented property => returns a Contour object (=hContour) HitPrimitive = hittest (hFig ) % undocumented function It turns out that the labels’ and lines’ HitTest property is ‘off’ by default, so, we also need to set them all to ‘on’:įunction myMouseClickCallback (hFig, eventData ) So the idea would be to set hContour.HitTest='off', in the hope that the mouse click would be registered on the graphic object directly beneath the mouse cursor, namely the label or contour line. We cannot simply click the contour and check the clicked object because that would just give us the hContour object handle rather than the individual Text or LineStrip. So the next logical step would be to trap the mouse-click event at the contour object level. I tried searching in the internal/undocumented properties, but nothing came up. Unfortunately, Text, LineStrip and TriangleStrip objects do not posses a ButtonDownFcn or UIContextMenu property, not even hidden. Next, how can we set a custom context-menu for individual labels and contour lines? A discussion of the various combinations of acceptable color properties can be found here. Similar transparency effects can also be applied to the LineStrip and Text objects.
Now for some more challenging questions: Customizing the colorįirst, can we modify the contour fill to have a semi- (or fully-) transparent fill color? – indeed we can:Ĭontour plot in HG2, with and without transparency Readers who are interested in Matlab internals can explore the bean adapters using a combination of my getundoc and uiinspect utilities. However, I generally dislike working with the bean adapters, especially when there’s a much “cleaner” way to get these objects, in this case using the regular EdgePrims, FacePrims, TextPrims and SelectionHandle properties. Specifically, this object apparent has the public method browseableChildren(java(hContour)) which returns the list of all children (in our case, 41 text labels, 20 lines, and a single object holding a ListOfPointsHighlight that corresponds to the regular hidden SelectionHandle property). – there’s an alternative way, using the Java bean adapter that is associated with each Matlab graphics object: java(hContour). StripData: īut how did I know these properties existed? The easiest way in this case would be to use my getundoc utility, but we could also use my uiinspect utility or even the plain-ol’ struct function. Here is a listing of the standard (non-hidden) properties exposed by these objects:įont: There are really numerous customization possibilities here.
Similarly, we may wish to hide some labels (by setting their Visible property to ‘off’) and make other labels bold (by setting their Font.Weight property to ‘bold’).
Any customization that we could do to the axle LineStrips can also be applied to contour LineStrips, and vice versa.įor example, to achieve the appearance of a topographic map, we might want to modify some contour lines to use dotted LineStyle and other lines to appear bold by having larger LineWidth.
Note that the LineStrip objects here are the same as those used for the axes Axles, which I described a few months ago. VertexData = single ( ) % Label location in data units