question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ticks: Labels appear and disappear on an auto-scrolling axis

See original GitHub issue

Bug Report

Issue:

Currently I am trying to implement a scrolling mechanism to view live data. It differs from the example in the cookbook as the Electrocardiogram strip chart only showed a certain slice of time, and all the data was coming in at the same interval. In my case data is coming in at different intervals, in a scatter plot instead of a signal plot. In order to do the scrolling, I update the axis limits every X milliseconds. This results in a scrolling animation, but causes the axis ticks to flicker in and out.

flickering

Trying to do just AxisPan causes the X axis to grow as if it was set to AxisAuto.

Reproducing:

  // adjust the axis limits only when needed
  var axisLimits = Plot_UserControl.Plot.GetAxisLimits();
  var currentRange = (DateTime.FromOADate(axisLimits.XMax) - DateTime.FromOADate(axisLimits.XMin)).TotalSeconds;
  double slidingPercentage = 0.95;

  var currentPoint = DateTime.Now;

  var max = currentPoint.AddSeconds(currentRange * (1 - slidingPercentage));
  var min = currentPoint.AddSeconds(-currentRange * slidingPercentage);

  Plots.SetAxisLimitsX(xMin: min.ToOADate(), xMax: max.ToOADate());

System Details

  • ScottPlot Version: 4.1.63?
  • Operating System: Windows 10
  • Application Type: WinForms
  • .NET Version: .Net 6

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nassalehcommented, Jun 10, 2022

@swharden That fixed my issue. Thank you so much!

1reaction
swhardencommented, Jun 9, 2022

@nassaleh this is an interesting effect! Does using a custom tick formatter like this help your ticks be more consistent? Notice I never call DateTimeFormat()

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        formsPlot1.Plot.XAxis.TickLabelFormat(CustomTickFormatter);
    }

    static string CustomTickFormatter(double position)
    {
        DateTime dt = DateTime.FromOADate(position);
        return $"{dt.Hour:00}:{dt.Minute:00}:{dt.Second:00}";
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        DateTime rightEdgeTime = DateTime.Now;
        double x2 = rightEdgeTime.ToOADate();
        double x1 = rightEdgeTime.AddSeconds(-20).ToOADate();
        formsPlot1.Plot.SetAxisLimitsX(x1, x2);
        formsPlot1.Refresh();
    }
}

formatter

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xaxis-Tick labels have disappeared plotting with pandas ...
When I create a 1-col 2-rows gridspec however, as soon as I plot onto the first (upper row) axes using pandas.DataFrame.plot() , the...
Read more >
Tick Labels disappear when chart is scrolled · Issue #6741
When X axis is scrolled, tick labels for some columns disappear and reappear. It seems tick labels are being recalculated on chart scrolling...
Read more >
Why do the labels of the last tick marks disappear when I ...
For some reason when axes location is set at origin, the labels of the final tick marks disappear. I have no idea how...
Read more >
How to Hide Axis Text Ticks or Tick Labels in Matplotlib?
The Matplotlib library by default shows the axis ticks and tick labels. Sometimes it is necessary to hide these axis ticks and tick...
Read more >
Origin Help - The Tick Labels Tab
The tick labels derived from column names or labels are positioned along the axis such that the numeric axis scale value equals the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found