how to just plot PlotArea ;

May 8, 2012 at 6:23 AM

Hi Objo,

   i want just draw plotArea, if PlotModel contain  axes, the plot will render axe majorLabel;

how i custom plotModel or axis  (ether element) to just render PlotArea in wpf( not measure axis and title) but i need plot gridline?  very thanks

 ////                LegendPosition (LegendPlacement=Outside)
    //// +               +-----------------------------------+                 +
    ////                 |              Title                |
    ////                 |            Subtitle               |
    ////                 +-----------------------------------+
    ////                 |TopLeft       TopCenter    TopRight|
    ////                 +-----------------------------------+
    ////                 |              Top axis             |
    //// +----------+----+-----------------------------------+-----+-----------+
    //// |LeftTop   |    |                                   |     |RightTop   |
    //// |          |    |                                   |     |           |
    //// |          |Left|                                   |Right|           |
    //// |LeftMiddle|axis|              PlotArea             |axis |RightMiddle|
    //// |          |    |                                   |     |           |
    //// |          |    |                                   |     |           |
    //// |LeftBottom|    |                                   |     |RightBottom|
    //// +----------+----+-----------------------------------+-----+-----------+
    ////                 |             Bottom axis           |
    ////                 +-----------------------------------+
    ////                 |BottomLeft BottomCenter BottomRight|
    //// +               +-----------------------------------+   


May 8, 2012 at 6:59 AM

axis have ShowMinorTicksProperty, if i add ShowMajorLabelProperty (bool) to decide wether render majorlebal ,it is possible?

May 12, 2012 at 9:59 AM

Do you want to hide the axis? Then try IsAxisVisible = false

Jul 26, 2012 at 2:31 PM

I now use this to hide my axes sometimes, but the area used by the plot(model?) is still the same.

Is it possible to expand the plotarea instead of just showing empty space where the axes used to be?

Jul 27, 2012 at 12:50 PM

I'm wondering the same thing as Tech_Junkie.  I'm trying to put a large number of graphs in a vertical stack panel and want the spacing to be as tight as possible.  Ideally, there would be no vertical area outside the plot area - so for the y values plotarea and plotandaxis area would be identical.  Can this be done?

Aug 6, 2012 at 5:59 PM

Tech_Junkie et al,

I was able to eliminate my vertical space by working with both the PlotModel and Axis.  For the PlotModel object, I set:

PlotMargins to (0,0,0,0)
Padding to (0,0,0,0)
TitleFontSize to 0
SubtitleFontSize to 0
TitlePadding to 0

This eliminated the space above the plot that would normally be title and gets rid of some empty space below the plot as well.  To get rid of the rest of the empty space below the plot, I had to derive classes from the axis classes I used for the horizontal axes.  Specifically, I had been using LinearAxis and CategoryAxis for my horizontal axes depending on the kind of plot I was using.  I derived a custom class from each of those and overrode the Measure function:

public override OxySize Measure(IRenderContext

rc) {    return new OxySize (0,0); }



 I also created constructors to match the base class.  Then I used my new custom class for my plots.  It would be a bit more elegant to put to check if the axis were visible and if so, call the base class measure function.  Otherwise, return 0 size as I did above.  As it is, the base class uses the same amount of room whether the axis is visible or not - that seems like a bug to me, but maybe it's intentional.  My change eliminates all space for the axes. 

Aug 7, 2012 at 10:25 AM

Sounds like this should work, I'll try the oxysize(0,0) out on my axes to see if this is what I need.


Aug 10, 2012 at 11:29 AM
Edited Aug 10, 2012 at 11:30 AM

This does indeed work, this is my axis:


public class InvisibleAxis : Axis
        public override bool IsXyAxis()
            return true;

        public override OxySize Measure(IRenderContext rc) { return new OxySize(0, 0); }


And this is the way I implement it:


                Model.PlotMargins = new OxyThickness(0,0,0,0);
                Model.Padding = new OxyThickness(0,0,0,0);
                Model.TitleFontSize = 0;
                Model.SubtitleFontSize = 0;
                Model.TitlePadding = 0;


                Model.Axes.Add(new InvisibleAxis { Position = AxisPosition.Bottom });
                Model.Axes.Add(new InvisibleAxis { Position = AxisPosition.Left });
Aug 23, 2012 at 2:02 PM

Did you see the "Source\Examples\Silverlight\SparklineDemo"? I don't think it is necessary to create a custom InvisibleAxis, just set IsAxisVisible = false.

Aug 7, 2014 at 3:22 PM
How can I get the actual width of an axis?

Aug 8, 2014 at 8:38 AM
I think you can get the value from ActualPlotMargins or PlotArea. Note that the plot must be updated before these properties can be used.