Message Boards Message Boards

How Can I Make a HorizontalGauge Bigger?

Posted 10 years ago

Hello everyone,

The HorizontalGauge is a neat control but it displays so small, with a tiny font size. Is there any way to make it bigger?

Gregory

POSTED BY: Gregory Lypny
4 Replies

This helps with some of your requirements (skipping the placement of the value above the triangle) and substitutes your requirement for a value of 156 to appear as a ScaleDivisions with the behavior of not going above 156 (similar with not going below 12 at the other end):

HorizontalGauge[
 Dynamic[x, (x = Which[# < 12, 12, # > 156, 156, True, #]) &], {0, 
  160}, ImageSize -> 500, BaseStyle -> 11, 
 GaugeLabels -> Placed[Dynamic[x], Above], ScaleDivisions -> 17]

The need to have the GaugeMarkers comprise of a triangle with the value above it can be done with a custom version. Here it uses a disk, following the documentation example in the documentaiton for GaugeMarkers-- it can be reworked to use a downward pointing triangle though (but which I am going to leave to you to work out ;-) )....

Module[{marker},
 marker[{{xmin_, xmax_}, {ymin_, ymax_}}, value_, 
   meta_] := {Text[
    Style[value, 11, Black], {Mean[{xmin, xmax}], ymax + ymax/2}], 
   Disk[{Mean[{xmin, xmax}], Differences[{ymin, ymax}][[1]]/2}, .015]};

 HorizontalGauge[
  Dynamic[x, (x = Which[# < 12, 12, # > 156, 156, True, #]) &], {0, 
   160}, ImageSize -> 500, BaseStyle -> 11, ScaleDivisions -> 17, 
  GaugeMarkers -> marker]
 ]
POSTED BY: David Reiss
Posted 10 years ago

Very cool. I learned a lot from this.

Thanks once again, David.

Gregory

POSTED BY: Gregory Lypny

When in doubt always check the Options:

In[9]:= Options[HorizontalGauge]

Out[9]= {AlignmentPoint -> Center, AspectRatio -> Automatic, 
 Axes -> False, AxesLabel -> None, AxesOrigin -> Automatic, 
 AxesStyle -> {}, Background -> None, BaselinePosition -> Automatic, 
 BaseStyle -> {}, ColorOutput -> Automatic, 
 ContentSelectable -> Automatic, CoordinatesToolOptions -> Automatic, 
 DisplayFunction :> $DisplayFunction, Epilog -> {}, 
 FormatType :> TraditionalForm, Frame -> False, FrameLabel -> None, 
 FrameStyle -> {}, FrameTicks -> Automatic, FrameTicksStyle -> {}, 
 GaugeFaceElementFunction -> Automatic, GaugeFaceStyle -> Automatic, 
 GaugeFrameElementFunction -> Automatic, GaugeFrameSize -> Automatic, 
 GaugeFrameStyle -> Automatic, GaugeLabels -> None, 
 GaugeMarkers -> Automatic, GaugeStyle -> Automatic, 
 GridLines -> None, GridLinesStyle -> {}, ImageMargins -> 0., 
 ImagePadding -> All, ImageSize -> Small, ImageSizeRaw -> Automatic, 
 LabelStyle -> {}, Method -> Automatic, 
 PerformanceGoal :> $PerformanceGoal, PlotLabel -> None, 
 PlotLegends -> None, PlotRange -> All, PlotRangeClipping -> False, 
 PlotRangePadding -> Automatic, PlotRegion -> Automatic, 
 PreserveImageOptions -> Automatic, Prolog -> {}, RotateLabel -> True,
  ScaleDivisions -> Automatic, ScaleOrigin -> Automatic, 
 ScalePadding -> Automatic, ScaleRanges -> Automatic, 
 ScaleRangeStyle -> Automatic, ScalingFunctions -> None, 
 TargetUnits -> Automatic, Ticks -> Automatic, TicksStyle -> {}}

So here is a possibility:

HorizontalGauge[55, {0, 100}, ImageSize -> 400, BaseStyle -> 14]
POSTED BY: David Reiss
Posted 10 years ago

Excellent tip! Thank you, David. In experimenting with these options, there are three other things that I have not been able to do.

  1. Display the maximum value of the scale as the last tick when the maximum value is not divisible by 10. I have a scale that runs from 0 to 156. No matter how I set ScaleDivisions, I cannot get 156 to appear as the last tick. The best I can do is 150.

  2. I cannot get the selected value to display above the marker, that is, move along with the marker. I tried

    GaugeLabels -> Placed["Value", Dynamic[x]]

but that is incorrect.

  1. Prevent values less than 12 from being selected. I want to stop the marker from being moved below 12, and 0 to 12 always being highlighted.

Any thoughts?

Gregory

POSTED BY: Gregory Lypny
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