ScottPlot/ScottPlot

AvaPlot does not show the bottom Axis Label under any circumstances

nicki419 opened this issue · 2 comments

Issue: The bottom Axis' label does not render. Using a box outside the plot shows that there is not enough text to show the label to begin with.

ScottPlot Version: 5.0.32

Code Sample:
UserControl.xaml:

<StackPanel Grid.Column="2" Orientation="Vertical">
  <Border CornerRadius="3" BorderThickness="2" BorderBrush="#d1d1d1">
    <ScottPlot:AvaPlot Margin="0,-15,0,0" HorizontalAlignment="Stretch" Height="350" Name="HeatPlot" />
  </Border>
  <ScottPlot:AvaPlot Margin="0,15,0,0" HorizontalAlignment="Stretch" Height="350" Name="ElectricityPlot" />
</StackPanel>``

UserControl.cs:

AvaPlot? avaPlot = this.FindControl<AvaPlot>(name);
        
if(avaPlot == null) return;
avaPlot.Reset();

var scatter = avaPlot.Plot.Add.Scatter(args.xData.ToArray(), args.yData.ToArray());
avaPlot.Plot.Title(args.title, 25);
avaPlot.Plot.Axes.Left.Label.Text = args.yName;
avaPlot.Plot.Axes.Bottom.Label.Text = args.xName;
avaPlot.Plot.Axes.Bottom.Label.ForeColor = Colors.Black;


//HeatPlot.Plot.YLabel(args.yName);
avaPlot.Plot.Axes.DateTimeTicksBottom();
avaPlot.Plot.Axes.AutoScale();

avaPlot.Refresh();

Update: It seems to be related to the DateTimeTicks. Uncommenting that line shows the bottom label. However, of course, that results in my data being displayed incorrectly.

Solved: The Label Text has to be set AFTER DateTimeTicksBottom.