how to just plot PlotArea ;

Oystein Bjorke 6 years ago 0
This discussion was imported from CodePlex

ProCodeMyth wrote at 2012-05-08 08:23:

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|
    //// +               +-----------------------------------+   


procodemyth wrote at 2012-05-08 08:59:

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

objo wrote at 2012-05-12 11:59:

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

Tech_Junkie wrote at 2012-07-26 16:31:

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?

PythagDev wrote at 2012-07-27 14:50:

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?

PythagDev wrote at 2012-08-06 19:59:

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. 

Tech_Junkie wrote at 2012-08-07 12:25:

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


Tech_Junkie wrote at 2012-08-10 13:29:

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 });

objo wrote at 2012-08-23 16:02:

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

jcma86 wrote at 2014-08-07 17:22:

How can I get the actual width of an axis?


objo wrote at 2014-08-08 10:38:

I think you can get the value from ActualPlotMargins or PlotArea. Note that the plot must be updated before these properties can be used.