-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
Issue:
I don't understand why this code does not work.
I tried to plot a horizontal line at y-value of 5.0, and it doesn't work.
I want to plot my data in two parts: yesterday's data colored blue, and today's data colored black.
ScottPlot Version:
5.0.47
Code Sample:
using ScottPlot;
public class Program
{
public static void Main()
{
var plt = new ScottPlot.Plot();
plt.ScaleFactor = 2;
plt.Clear();
double[] X_scatter = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
double[] Y_scatter = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
// Part 1: Plot yesterday's data, colored blue.
var yesterdaysX = X_scatter.Take(5).ToArray();
var yesterdaysY = Y_scatter.Take(5).ToArray();
var scatter1 = plt.Add.Scatter(yesterdaysX, yesterdaysY);
scatter1.Color = Colors.Blue;
scatter1.LineWidth = 0;
scatter1.MarkerShape = MarkerShape.FilledCircle;
scatter1.MarkerSize = 5;
scatter1.Axes.YAxis = plt.Axes.Right;
plt.Axes.Left.IsVisible = false;
// Part 2: Plot today's data colored black.
var todaysX = X_scatter.Skip(5).ToArray();
var todaysY = Y_scatter.Skip(5).ToArray();
var scatter2 = plt.Add.Scatter(todaysX, todaysY);
scatter2.Color = Colors.Black;
scatter2.LineWidth = 0;
scatter2.MarkerShape = MarkerShape.FilledCircle;
scatter2.MarkerSize = 5;
scatter2.Axes.YAxis = plt.Axes.Right;
plt.Add.HorizontalLine(5.0, width: 1, color: Colors.Green);
plt.SavePng("../../../horizontal_line.png", 800, 800);
}
}
When I run this code, I get:
Notice the left side of the plot is cut off.
Charles
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
