0

[Edit: I submitted an issue about this on the OxyPlot GitHub]

I have an OxyPlot cartesian graph in a WPF Window with some FunctionSeries. When I set PositionAtZeroCrossing at true for both the axes, several problems appear :

1) The titles are not displayed correctly, one doesn't even appear. Changing the value of TitlePosition does not seem to change anything.

2) When zooming in or moving around, the x axis goes outside the graph area, as shown below : screenshot

Both problems do not appear when PositionAtZeroCrossing is not set as true.

I am wondering if there is a correct way to fix those problems, or a workaround (I am not familiar with OxyPlot).

//My PlotModel is binded to the Model of a PlotView in my WPF control.

//FonctionQlimPlim, maxX, maxY, minX and maxY are defined elsewhere
PlotModel plot = new PlotModel() 
{
    PlotType = PlotType.Cartesian
};

plot.Axes.Add(new LinearAxis()
{
    Position = AxisPosition.Bottom,
    Minimum = minX,
    Maximum = maxX,
    Title = "Q (kVAR)",
    PositionAtZeroCrossing = true 
});

plot.Axes.Add(new LinearAxis()
{
    Position = AxisPosition.Left,
    Minimum = minY,
    Maximum = maxY,
    Title = "P (kW)",
    PositionAtZeroCrossing = true
});

//One of the FunctionSeries
var f = FonctionQlimPlim;
f.Color = OxyColors.Red;
plot.Series.Add(f);
cmousset
  • 625
  • 7
  • 21

2 Answers2

1

It seems like the usage for this property is something along the following:

Let's assume your input is an x (horizontal),y (vertical) graph. Let's say your x values go from 1 to 20, and let's assume that your y values will be a random number between -10 and 10.

So, we're expecting to see a graph with a 20point jumping up and down randomly.

When you set the axis PositionAtZeroCrossing, you're telling Oxyplot to put it where the crossing is at. Here's some screenshots to help you out: Link to bigger image.

Screenshots

So, depending on where your zero is, it might be far far outside of your viewable screen, and hence it seems to not be there.

To be honest, I don't see the point in setting them bot to true, but it might suit some needs I guess.

Noctis
  • 11,507
  • 3
  • 43
  • 82
  • Thanks. What I tried to do is to initially get my Y axis on the x=0 which is at the center of the graph (the min/max are computed for that)for which `PositionAtZeroCrossing` would do the trick nicely if not for those problems. When the option is activated for the Y axis, there's both the X axis outside the graph and a 2d line intersecting the Y axis at y=0. It's this 2d line, and the Y axis, which go outside the graph when zooming with 0 outside the graph. It is very obvious in my case as the graph is not the only element in the window. It seems buggy, I might have to give up 0-crossing axis. – cmousset Sep 19 '14 at 13:00
  • I also notice that on your exemple, the Y title also does not appear when `PositionAtZeroCrossing` is true for it. Any idea on the why or on how to place it ? – cmousset Sep 19 '14 at 13:02
  • nope ...no idea really ... you might want to drop the developers a line, or look at the source code :) – Noctis Sep 19 '14 at 13:51
  • Yeah I think I'm going to do that. Thanks anyway ;) – cmousset Sep 19 '14 at 15:12
0

It was a bug, traced here, that was fixed in October 2014.

cmousset
  • 625
  • 7
  • 21