how to position the axis title · Issue #1721 · oxyplot/oxyplot · GitHub
Skip to content

how to position the axis title #1721

Closed
Closed

Description

@aliridha1510

Hello, I want to set the title for the axes outside the diagram,

Platform:
.NET version:
WPF
Oxyplot.wpf Version 1.0.0

example code

        public void InitModel()
        {

            XAxis = new LinearAxis
            {
                Position = AxisPosition.Top,
                PositionTier = 0,
                AxislineStyle = LineStyle.Solid,
                Minimum = 0,
                AxislineColor = OxyColors.Red,
                StartPosition = 0.5,
                EndPosition = 1,
                PositionAtZeroCrossing = true,
                AbsoluteMinimum = 0,
                Title = "title1",
                Unit ="ABCABC",
                AxisTitleDistance = 0,
                TitlePosition = -0.09,

            };
            Model.Axes.Add(XAxis);

            XAxis2 = new LinearAxis
            {
                Position = AxisPosition.Top,
                PositionTier = 0,
                AxislineStyle = LineStyle.Solid,
                Minimum = 0,
                AxislineColor = OxyColors.Gold,
                StartPosition = 0.5,
                EndPosition = 0,
                PositionAtZeroCrossing = true,
                IsAxisVisible = true,
                AbsoluteMinimum = 0,
                Title = "title2",
                Unit = "ABCABC",
                AxisTitleDistance =  0,
                TitlePosition = -0.09,



            };
            Model.Axes.Add(XAxis2);
            YAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                AxislineStyle = LineStyle.Solid,
                Minimum = 0,
                AxislineColor = OxyColors.Green,
                PositionTier = 10,
                StartPosition = 0.5,
                EndPosition = 1,
                PositionAtZeroCrossing = true,
                AbsoluteMinimum = 0,
                AbsoluteMaximum = 1000,
                Title = "title3",
                Unit = "ABCABC",
                AxisTitleDistance = 0,
                TitlePosition = -0.09,
                AxisTickToLabelDistance = 10,


            };
            Model.Axes.Add(YAxis);
            YAxis2 = new LinearAxis
            {
                Position = AxisPosition.Right,
                AxislineStyle = LineStyle.Solid,
                Minimum = 0,
                AxislineColor = OxyColors.Violet,
                PositionTier = 0,
                StartPosition = 0.5,
                EndPosition = 0,
                PositionAtZeroCrossing = true,
                AbsoluteMinimum = 0,
                Title = "title4",
                Unit = "ABCABC",
                AxisTitleDistance = 0,
                TitlePosition = -0.09,

            };
            Model.Axes.Add(YAxis2);
            Model.PlotAreaBorderThickness = new OxyThickness(1, 1, 1, 1);

        }
    }

image

image

Any ideas? Thank you in advance!

Activity

  1. VisualMelon commented on Nov 25, 2020

    @VisualMelon
    Contributor

    I don't believe this is possible with the existing Axis provisions (in any version). The current axis rendering routines are unfortunately rather inextensible, and I expect the easiest way to achieve what you want is to provide the axis titles as separate (screen space) annotations and modify the plot margins manually.

  2. aliridha1510 commented on Nov 25, 2020

    @aliridha1510
    Author

    you mean that I do not define axis titles for current axes and provide an annotation as an Axis title ?
    can you please give me a small example .

  3. VisualMelon commented on Nov 25, 2020

    @VisualMelon
    Contributor

    Here's an example Implementation of a 'side annotation': https://gist.github.com/VisualMelon/194f3aecb83a76060dfb39dc4ab97586

    Hopefully it should provide a sensible example from which to work, though you might need to mess with the clipping to make it work in 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions