This project is read-only.

Fixing range of scatter plot axes

Jun 3, 2011 at 2:26 PM


Could anyone tell me how to fix the scale of x and y axis to a predetermined range, please? I'm using a scatter plot and want to stop rescaling of the axes every time it updates with new data, even if this means that some points are not displayed.



Jun 8, 2011 at 5:56 PM

Me too. Anyone please help to fix this problem. Thanks very much.


Jun 8, 2011 at 10:09 PM

Assuming you are using an observabledatasource<T>, the range shown is dependent on the enumerator returned by

public IPointEnumerator GetEnumerator(DependencyObject context)
            return new ObservableIterator(this);

so. to fix a scale I made class FixedWindowSource <T> : observabledatasource<T>

give it a few properties on how you want to limit your range (a min/max, etc.)  I'm going to assume for the time being that you will use min/max fields.

so finally make a new iterator class, the only changes here (between FixedWindowIterator and the observableiterator)  are in the constructor

public FixedWindowIterator(FixedWindowSource<T> dataSource)
                this.dataSource = dataSource;
                if (dataSource.collection.Count == 0) enumerator = dataSource.collection.GetEnumerator();

//obviously you may need to alter this if you're using xmapping etc.

                        double max = dataSource.Max;
                        double min = dataSource.Min;
                        enumerator = (from c in dataSource.collection
                                      where dataSource.xyMapping(c).X >= min && dataSource.xyMapping(c).X <=max
                                      select c).GetEnumerator();

finally set the min and max as you want

Jun 9, 2011 at 9:42 AM

Thanks for your help, I'll give this a try.


Jun 9, 2011 at 12:47 PM

can't you just set the plotter's visible property each time the data is updated?

i.e. plotter.Visible = new DataRect(minX, minY, Width, Height);