Orientation of vertical axis titles · Issue #22 · oxyplot/oxyplot · GitHub
Skip to content

Orientation of vertical axis titles #22

Open

Description

@objorke

Imported from http://oxyplot.codeplex.com/workitem/9972

objo 2012-08-08 23:25
It should be possible to use horizontal text (positioned on the top) for the titles on vertical axes.

Activity

  1. datafj commented on Feb 14, 2021

    @datafj

    Here is my temporary solution for this issue:

    1. Set Y-axis title to "",
    2. Increase the padding of the Title: plotModel.TitlePadding = 20;
    3. Add a custom text annotation under the title, with position relative to PlotAndAxisArea.
    public class CustomTextAnnotation : Annotation
       {
           public CustomTextAnnotation()
           { }
    
           public string Text { get; set; }
           public double X { get; set; }
           public double Y { get; set; }
    
           public override void Render(IRenderContext rc)
           {
               base.Render(rc);
               double pX = PlotModel.PlotAndAxisArea.Left + X;
               double pY = PlotModel.PlotAndAxisArea.Top + Y;
               rc.DrawMultilineText(new ScreenPoint(pX, pY), Text, TextColor, Font, FontSize, FontWeight);
           }
       }
    
    plotModel.Annotations.Add(new CustomTextAnnotation()
                {
                    Text = YAxisTitle,
                    X = 0,
                    Y = -16,
                    Font = "Whatever you like",
                    FontSize = 12,
                    TextColor = OxyColors.Black
                });
    
  2. VisualMelon commented on Feb 14, 2021

    @VisualMelon
    Contributor

    Linking #1640 where I'm working on a more general solution

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