Any interest in a gauge control?
Johan20D wrote at 2014-07-18 07:57:
HeatMapSeries Axis Problems [Solved]
guevara123 wrote at 2013-03-08 13:21:
I am currently trying to create a STFT Plot with HeatMapSeries, but i encountered a problem with setting the axis right..
As you can see both axis have the same size and i dont know why.. My time-Axis(x-Axis) should be much smaller. The strange thing is, when I plot the HeatMap with flipped Axis( time- axis = y- axis, frequency axis -> x-axis ), than the plot is correctly drawn.
Here the interesting parts of the code:
double x0 = 0;
double x1 = currentTime;
double y0 = 0;
double y1 = maxFrequency;
peaksData = .magnitudedata; // double[currenTime.Length, maxFrequency.Length]
heatMap = new HeatMapSeries { X0 = x0, X1 = x1, Y0 = y0, Y1 = y1, Data = peaksData };
temp.Series.Add(heatMap);
var cs = new ContourSeries
{
Color = OxyColors.Black,
FontSize = 0,
ContourLevelStep = 1,
LabelBackground = null,
ColumnCoordinates =timeValues, //array with length = currenTime(rounded)
RowCoordinates= frequenyValues,//array with length = maxFrequency
Data = peaksData
};
The same happens for the HeatMapSeries Example when I change the values to, double x0 = 3;
double x1 = 4;
double y0 = 5;
double y1 = 8;
then i will get a lot of white space in the Plot..Thanks in advance for your help.
guevara123 wrote at 2013-03-11 20:23:
guevara123 wrote at 2013-03-13 14:29:
/// <summary>
/// Updates the max/minimum values.
/// </summary>
protected internal override void UpdateMaxMin()
{
[...]
this.XAxis.Include(this.MinX);
this.XAxis.Include(this.MaxX);
this.YAxis.Include(this.MinY); //this.XAxis.Include(this.MinY);
this.YAxis.Include(this.MaxY); //this.XAxis.Include(this.MaxY);
[...]
}
objo wrote at 2013-03-13 20:28:
NejibCh wrote at 2013-04-27 05:53:
I had many challenges to set the contours, contour labels and colorAxis position (Needed to add a transparent axis to push the ColorAxis further for plotArea)
By the way this is great tool. Much better than some marketed tools "like Infragistics for example).
Good job guys.
!!!!!!!!!!!!!!!!!!!!!!!!!!! ----------------------- in the XAML
<Window x:Class="TreeMapInfragistics.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
xmlns:oxy2="clr-namespace:OxyPlot.Series;assembly=OxyPlot"
Title="MainWindow" Height="610" Width="610">
<Grid>
<oxy:Plot x:Name="MyOxyPlot" Model="{Binding MyPlotModelTab3}"/>
</Grid>
</Window> !!!!!!!!!!!!!!!!!!!!!!!!!!! ----------------------- in the ViewModel
using System;
using System.Linq;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;
namespace HeatMapWithContours
{
public class MainViewModel: BaseViewModel
{
public double [] mnMxXY = new double[6];
public double[] WOB;
public double[] RPM;
public MainViewModel()
{
UpdateChart();
}
// ..........................................
private PlotModel _myPlotModelTab3;
public PlotModel MyPlotModelTab3
{
get { return _myPlotModelTab3; }
set
{
_myPlotModelTab3 = value;
OnPropertyChanged("MyPlotModelTab3");
}
}
public void UpdateChart()
{
double[,] MyData = GenerateData();
#region HeatMapSeries
var hm = new HeatMapSeries();
hm.Data = MyData;
hm.Selectable = false;
hm.X0 = mnMxXY[0]; // Min X-axis
hm.X1 = mnMxXY[1]; // Max X-axis
hm.Y0 = mnMxXY[2]; // Min Y-axis
hm.Y1 = mnMxXY[3]; // Max Y-axis
#endregion
#region ContourSeries
var cs = new ContourSeries()
{
// ..............
ColumnCoordinates = WOB, //yvalues
RowCoordinates = RPM,//xvalues
Data = MyData,
// ............
ContourLevelStep = 5,
StrokeThickness = 0.5,
LineStyle = LineStyle.Solid,
Color = OxyColors.Gray,
//ContourColors = new[] { OxyColors.SeaGreen, OxyColors.RoyalBlue, OxyColors.IndianRed },
// ...............
LabelFormatString = "[0.00]",
LabelBackground = null,
//LabelSpacing = double.NaN,
//Font = null,
//LabelStep = 10,
FontSize = 11,
FontWeight = FontWeights.Normal,
TextColor = OxyColors.Black
//Background = OxyColor.FromAColor(220, OxyColors.White),
//TrackerFormatString = null,
};
#endregion
#region X- Axis
LinearAxis xAxis = new LinearAxis
{
Position = AxisPosition.Bottom,
Title = "RPM",
ClipTitle = true,
TitlePosition = 0.5,
MinorGridlineStyle = LineStyle.Dot,
MajorGridlineStyle = LineStyle.Dot,
MinorGridlineThickness = 1,
MajorGridlineThickness = 1,
IsAxisVisible = true,
IsZoomEnabled = false,
IsPanEnabled = false,
Angle = 0,
AxisTitleDistance = 4,
AxisTickToLabelDistance = 4,
MajorTickSize = 7,
MinorTickSize = 4,
Minimum = mnMxXY[0],
Maximum = mnMxXY[1],
ShowMinorTicks = true
};
#endregion
#region Y- Axis
LinearAxis yAxis = new LinearAxis
{
Position = AxisPosition.Left,
Title = "WOB",
ClipTitle = true,
TitlePosition = 0.5,
MinorGridlineStyle = LineStyle.Dot,
MajorGridlineStyle = LineStyle.Dot,
MinorGridlineThickness = 1,
MajorGridlineThickness = 1,
IsAxisVisible = true,
IsZoomEnabled = false,
IsPanEnabled = false,
Angle = 0,
AxisTitleDistance = 4,
AxisTickToLabelDistance = 4,
MajorTickSize = 7,
MinorTickSize = 4,
Minimum = mnMxXY[2],
Maximum = mnMxXY[3],
ShowMinorTicks = true
};
#endregion
#region Y1- Axis
LinearAxis y2Axis = new LinearAxis
{
Position = AxisPosition.Right,
IsAxisVisible = true,
IsZoomEnabled = false,
IsPanEnabled = false,
TicklineColor = OxyColors.Transparent,
AxislineColor = OxyColors.Transparent,
TextColor = OxyColors.Transparent
};
#endregion
#region ColorAxis
ColorAxis cAxis = new ColorAxis
{
Position = AxisPosition.Right,
PositionTier = 1,
Palette = OxyPalettes.Jet(500),
HighColor = OxyColors.Red,
LowColor = OxyColors.Blue,
Minimum = mnMxXY[4],
Maximum = mnMxXY[5],
StartPosition = 0.05,
EndPosition = 0.95,
IsAxisVisible = true,
Angle = 0,
AxisTitleDistance = 4,
AxisTickToLabelDistance = 4,
MajorTickSize = 7,
MinorTickSize = 4,
ShowMinorTicks = true,
UseSuperExponentialFormat = true
};
#endregion
#region PlotModel
PlotModel tempPlotModel = new PlotModel();
tempPlotModel.AutoAdjustPlotMargins = true;
tempPlotModel.PlotAreaBackground = OxyColors.Red;
tempPlotModel.Title = "Critical Speed Map (XPos)";
tempPlotModel.TitleFontWeight = FontWeights.Normal;
tempPlotModel.PlotAreaBorderThickness = 1;
tempPlotModel.PlotAreaBorderColor = OxyColors.Black;
tempPlotModel.Axes.Add(xAxis);
tempPlotModel.Axes.Add(yAxis);
tempPlotModel.Axes.Add(y2Axis);
tempPlotModel.Axes.Add(cAxis);
tempPlotModel.Series.Add(hm);
tempPlotModel.Series.Add(cs);
#endregion
MyPlotModelTab3 = tempPlotModel;
}
#region Generate Data
private double[,] GenerateData()
{
..........
}
} }
Steps with LogarithmicAxis
WeirdNoise wrote at 2013-07-22 14:08:
I'm trying to put together a little tool for displaying audio measurements. Such plots do usually have two logarithmic axes, though the amplitude axis is scaled linear by using dB.
The frequency axis, however, should be scaled logarithmic and has to cover approximately the human range of audibility from 20 Hz to 20 kHz. If I set up a plot using a logarithmic oxyPlot, I get something like this:
I would like to have more displayed Steps (frequency labels) on the frequency axis, like this:
Obviously, I can't just adjust the Axis' Base, as I would get rather odd numbers. Is there any way to achieve such an axis labeling with oxyPlot?
Thanks in advance
everytimer wrote at 2013-07-23 12:28:
willmoore88 wrote at 2013-08-07 09:15:
Inside LogarithmicAxis.cs, GetTickValues()....
if (d2 >= this.ActualMinimum && d2 <= this.ActualMaximum)
{
//minorTickValues.Add(d2);
majorTickValues.Add(d2);
}
WeirdNoise wrote at 2013-08-11 17:20:
it's been a while... Finally got to work on this.
everytimer: Thanks for pointing me in the right direction!
Main differences between my implementation and original (assuming base=10, but works with any other base):
-You can zoom out and display many decades without messing up the labels
-A Decade is subdivided if there's enough space for the labels
-The IntervalLength property is actually used by the algorithm
Example:
For several reasons, I did my fix in the form of a simple override.
In case anyone's interested and not bothered by a little VB:
Imports System.Math
Public Class MyLogAxis
Inherits Axes.LogarithmicAxis
Public Overrides Sub GetTickValues(ByRef majorLabelValues As IList(Of Double), ByRef majorTickValues As IList(Of Double), ByRef minorTickValues As IList(Of Double))
majorTickValues = New List(Of Double)
minorTickValues = New List(Of Double)
Dim screensize As Integer
If Me.IsHorizontal Then
screensize = Me.ScreenMax.X - Me.ScreenMin.X
Else
screensize = Me.ScreenMax.Y - Me.ScreenMin.Y
End If
Dim totalBW As Double = Log(Me.ActualMaximum, Me.Base) - Log(Me.ActualMinimum, Me.Base)
Dim BWratio As Double = width / totalBW
If totalBW < 1 Then
MyBase.GetTickValues(majorLabelValues, majorTickValues, minorTickValues)
ElseIf BWratio < Me.IntervalLength Then
Dim steps As Integer = Ceiling(Me.IntervalLength / BWratio)
Dim c As Double = Ceiling(Log(Me.ActualMinimum, Me.Base))
While c < Floor(Log(Me.ActualMaximum, Me.Base))
minorTickValues.Add(Round(Pow(Me.Base, c), 10))
If c Mod steps = 0 Then
majorTickValues.Add(Round(Pow(Me.Base, c), 10))
End If
c += 1
End While
Else
Dim c As Double = Floor(Log(Me.ActualMinimum, Me.Base))
Dim v As Double
Dim c2 As Double
Dim lower As Double
While c < Ceiling(Log(Me.ActualMaximum, Me.Base)) + 1
v = Pow(Me.Base, c)
If v > Me.ActualMinimum And v < Me.ActualMaximum Then
majorTickValues.Add(Round(v, 10))
End If
Dim a As Integer = 1
lower = c
While a < Me.Base
c2 = c + Log(a, Me.Base)
v = Pow(Me.Base, c2)
If v + 0.00001 >= Me.ActualMinimum And v <= Me.ActualMaximum + 0.00001 Then
minorTickValues.Add(Round(Pow(Me.Base, c2), 10))
If BWratio * Min(c2 - lower, c + 1 - c2) > Me.IntervalLength Then
majorTickValues.Add(Round(v, 10))
lower = c2
End If
End If
a += 1
End While
c += 1
End While
End If
majorLabelValues = majorTickValues
End Sub
End Class
everytimer wrote at 2013-08-11 19:38:
Flip view not changing view because of Plotview?
I think the swipe gesture not working when Plotview is on top.
Rectangle and Ellipse Selection Colour
Slxe wrote at 2014-05-16 18:40:
It seems like both RectangleAnnotation and EllipseAnnotation aren't checking if they're selected and changing the fill colour if they are. Noticed the slight difference when reviewing the source if it helps (in each's render methods):
PolygonAnnotation:
rc.DrawClippedPolygon( this.screenPoints, clipping, MinimumSegmentLength * MinimumSegmentLength, this.GetSelectableFillColor(this.Fill), this.GetSelectableColor(this.Color), this.StrokeThickness, this.LineStyle, this.LineJoin);
rc.DrawClippedLine( this.screenPoints, clippingRectangle, MinimumSegmentLength * MinimumSegmentLength, this.GetSelectableColor(this.Color), this.StrokeThickness, dashArray, this.LineJoin, this.aliased, null, clippedPoints.AddRange);
RectangleAnnotation:
rc.DrawClippedRectangle(this.screenRectangle, clipping, this.Fill, this.Stroke, this.StrokeThickness);
rc.DrawClippedEllipse(clipping, this.screenRectangle, this.Fill, this.Stroke, this.StrokeThickness);
objo wrote at 2014-05-16 19:53:
objo wrote at 2014-05-17 06:24:
I also aligned the DrawClipped* methods, now the clipping rectangle is the first parameter in all these methods.
Slxe wrote at 2014-05-17 15:42:
private void Annotation_OnMouseDown(object sender, OxyMouseDownEventArgs args) { if (((Annotation) sender).IsSelected()) ((Annotation) sender).UnSelect(); else ((Annotation) sender).Select(); } private void uiSelectAnnotsButton_OnCheckedChanged(object sender, EventArgs args) { foreach (Annotation a in ChartModel.Annotations) { if (((ToolStripButton) sender).Checked) a.MouseDown += Annotation_OnMouseDown; else a.MouseDown -= Annotation_OnMouseDown; } foreach (Annotation a in ChartModel.Annotations) a.Unselect(); } private void uiEditTextTextBox_OnKeyDown(object sender, EventArgs args) { if (args.KeyCode != Keys.Enter) return; foreach (Annotation a in ChartModel.Annotations.Where(a => a.IsSelected())) ((TextualAnnotation) a).Text = ((ToolStripTextBox) sender).Text; ChartModel.InvalidatePlot(false); }
Edit; you could also make them update as the text is entered, looks kinda cool. I opted for the enter key over it in the demo though:
private void uiEditTextTextBox_OnTextChanged(object sender, EventArgs args) { foreach (Annotation a in ChartModel.Annotations.Where(a => a.IsSelected())) ((TextualAnnotation) a).Text = ((ToolStripTextBox) sender).Text; ChartModel.InvalidatePlot(false); }
Contour plot, fill color and logarithmic scale
nhrl wrote at 2013-09-19 16:42:
I'm using Oxyplot as a library for .Net framework 4.0, in VB Express 2010 environment.
I'm trying to make contour plots and my questions are the following.
- Is it possible to have a logarithmic scale for the third axis ? If it is, what's the way to do it ?
- Is it possible to fill the gap between contour levels ?
NHRL
objo wrote at 2013-09-20 09:10:
Currently, it is not possible to fill the gap between the contour levels.
But you can add a HeatMapSeries before the ContourSeries - see the examples.
If you use a RangeColorAxis, I think you can get almost the same result.
nhrl wrote at 2013-09-20 10:41:
Indeed, I set the ContourLevels to {1,10,100,1000}, creating a logarithmic scale.
Concerning the HeatMapSeries, I did not managed to use it.
I have the following error :
La référence d'objet n'est pas définie à une instance d'objet.
with the following code :Dim Plotmodel1 As New PlotModel
Plotmodel1.Title = "Atlas de vagues - " & ComboBox1.SelectedItem
Dim linearAxis1 As New LinearAxis()
linearAxis1.Position = AxisPosition.Bottom
linearAxis1.Title = "Tz (s)"
linearAxis1.MajorGridlineStyle = LineStyle.Solid
linearAxis1.MinorGridlineStyle = LineStyle.LongDash
Plotmodel1.Axes.Add(linearAxis1)
Dim linearAxis2 As New LinearAxis()
linearAxis2.MajorGridlineStyle = LineStyle.Solid
linearAxis2.MinorGridlineStyle = LineStyle.LongDash
linearAxis2.Title = "Hs (m)"
Plotmodel1.Axes.Add(linearAxis2)
Dim contourSeries1 As New ContourSeries()
Dim heatMapSeries1 As New HeatMapSeries()
heatMapSeries1.X0 = tz_ss(0)
heatMapSeries1.X1 = tz_ss(UBound(tz_ss, 1))
heatMapSeries1.Y0 = hs_ss(0)
heatMapSeries1.Y1 = hs_ss(UBound(hs_ss, 1))
heatMapSeries1.Data = prob_ss
contourSeries1.ColumnCoordinates = tz_ss
contourSeries1.ContourLevels = {1, 10, 100, 1000, 10000}
contourSeries1.LineStyle = LineStyle.Solid
contourSeries1.StrokeThickness = 5
contourSeries1.ContourColors = {OxyColors.Aquamarine, OxyColors.Aqua, OxyColors.CadetBlue, OxyColors.Blue, OxyColors.Black}
contourSeries1.Data = prob_ss
contourSeries1.RowCoordinates = hs_ss
Plotmodel1.Series.Add(heatMapSeries1)
Plotmodel1.Series.Add(contourSeries1)
Plotmodel1.Background = OxyColors.White
Plotmodel1.PlotAreaBackground = OxyColors.White
Plot1.Model = Plotmodel1
If I add only the contourseries1 to the Plotmodel1, it works. But with the heatMapSeries1, it fails.nhrl wrote at 2013-09-20 16:00:
- On my oxyplot version, the method "Add" doesn't exist for the "Data" method of "Heatmapseries"
- The version of Oxyplot I use seems to be different of the one used for the exemple (?)
- I cannot reproduce the simple examples of Heatmapseries that are provided in the examplebrowser..
nhrl wrote at 2013-10-01 10:45:
objo wrote at 2013-10-01 22:09:
I added an issue on this: https://oxyplot.codeplex.com/workitem/10083
thanks!
objo wrote at 2013-10-01 22:51:
nhrl wrote at 2013-10-02 13:35:
Thank you for your answer. Unfortunately, it did not solve my problem.
Actually, I code in VB.net, not in C#.
I'm trying to translate the example code from C# to VB.net, but I have errors.
Particularly, I don't know how to translate this line :
heatMapSeries1.Data = new Double[100, 100];
And I think this line is important. Do you have any idea ?
objo wrote at 2013-10-02 13:42:
nhrl wrote at 2013-10-02 14:05:
heatmapseries1.Data = New Double(2, 2) {{1, 2, 3}, {3, 2, 1}, {1, 1, 1}}`
Now, here is my entire code :Plotmodel1.Title = "Atlas de vagues - " & ComboBox1.SelectedItem
Dim linearColorAxis1 As New LinearColorAxis()
linearColorAxis1.HighColor = OxyColors.Gray
linearColorAxis1.LowColor = OxyColors.Black
linearColorAxis1.Position = AxisPosition.Right
Plotmodel1.Axes.Add(linearColorAxis1)
Dim linearAxis1 As New LinearAxis()
linearAxis1.Position = AxisPosition.Bottom
linearAxis1.Title = "Tz (s)"
linearAxis1.MajorGridlineStyle = LineStyle.Solid
linearAxis1.MinorGridlineStyle = LineStyle.LongDash
linearAxis1.Position = AxisPosition.Bottom
Plotmodel1.Axes.Add(linearAxis1)
Dim linearAxis2 As New LinearAxis()
linearAxis2.MajorGridlineStyle = LineStyle.Solid
linearAxis2.MinorGridlineStyle = LineStyle.LongDash
linearAxis2.Title = "Hs (m)"
Plotmodel1.Axes.Add(linearAxis2)
Plotmodel1.Background = OxyColors.White
Plotmodel1.PlotAreaBackground = OxyColors.White
Dim heatmapseries1 As New HeatMapSeries
heatmapseries1.X0 = 0.5
heatmapseries1.X1 = 10.5
heatmapseries1.Y0 = 0.5
heatmapseries1.Y1 = 15.5
heatmapseries1.Data = New Double(2, 2) {{1, 2, 3}, {3, 2, 1}, {1, 1, 1}}
Plotmodel1.Series.Add(heatmapseries1)
Plot1.Model = Plotmodel1
But the error remain. Actually, visual studio doesn't return any error, but my plot is empty with the following text in red :OxyPlot paint exception : La référence d'objet n'est pas définie à une instance d'objet.
in english :OxyPlot paint exception : object reference not set to an instance of an object
Thank you again. NHRL
nhrl wrote at 2013-10-08 10:52:
I find OxyPlot is a wonderful toolbox, but it's a pity that I can't use its full capabilities..
Plot disappear in demo (oxyplot-a53ac6bf18cf )
sharethl wrote at 2014-03-12 17:28:
Open any plot, click "code" tab, and click "Plot" tab again, plot disappear,
This not only happens on demo, but also in avalondock.
in avalondock, it was able to show plot if window is floated. but now cannot show plot.
Thanks.
bradcarman wrote at 2014-03-12 17:59:
sharethl wrote at 2014-03-12 19:07:
WPF demo browser's "Add annotations" in "Mouse event" group, once click "Code" tab, and back to plot tab, mouse event won't update plot while mouse moving.
reproduce:
- Run oxyPlot.WPF Example,
- Select "Add annotations" in "Mouse events" group.
- Click "Code" tab,
- Click "Plot" tab.
- Use mouse to draw arrow, the arrow won't update during mouse moving.
Thanks.
tibel wrote at 2014-03-12 19:43:
line 777 should be removed, then it works ;-)
sharethl wrote at 2014-03-12 19:56:
Such a big library really cannot find out why if not familiar with it.
Thanks
objo wrote at 2014-03-12 22:26:
tibel: the intention with
currentlyAttachedModel
was to keep track of the PlotModel that is currently attached to the
Plot
control. This can also be the internalModel
that is used when
Model
is null. When the control is unloaded, the currentlyAttachedModel
should be null. I added a
currentModel
property that can be used in the UpdateModel
method. Or do you see better ways to solve this?
sharethl: I think the add annotations example is working again now :-) great to hear you would like to contribute! see http://oxyplot.org/doc/Contributions.html for more information
tibel wrote at 2014-03-13 07:32:
Only one thing:
ActualModel
property should also use currentModel
instead of
this.Model
.objo wrote at 2014-03-13 10:53:
Bar Series Drifting Upward
mkov wrote at 2014-01-21 02:33:
I have a nice OxyPlot setup with bar series and category axis on a WinForm. The thing is those bars jump up after I minimize and restore my form. I traced this down to this line in Render() method in BarSeriesBase.cs:
if (!this.IsStacked)
{
culprit -> categoryAxis.BarOffset[categoryIndex] += actualBarWidth;
}
I don't know why this code is needed as it keeps on incrementing BarOffset values with each Render call, but that doesn't always make a visual difference. Nevertheless, once commented out bars stay where I intended them to be. I can provide more context if
required. If possible, I'd like to request a fix. Thanks!
MK
objo wrote at 2014-01-25 22:56:
https://oxyplot.codeplex.com/workitem/10120
(I don't have time to solve this myself at the moment)
Export to PDF not working
thomasdr wrote at 2013-10-24 20:07:
When I export, the tick marks and the data series are not output.
I ran the Export Examples from the newest OxyPlot (2013.2.106.1) they act the same way. Any suggestions?
thomasdr wrote at 2013-10-25 13:59:
if (stroke.IsVisible() || thickness <= 0)
{
return;
}
If I change that to if (!stroke.IsVisible() || thickness <= 0)
{
return;
}
my plot lines draw.objo wrote at 2013-10-25 22:29:
Servicio de atención al cliente por UserEcho