XScaleFormat problem


  • Anonymous

    Hey there,

    I tried to get the Custom Scale labels working because of an irregular step
    size on x-axis, but I'm a bit mad right now, because it's not working.

    What I try to do, is the following:

    I have physical charts. There are counts over a wavelength. Sometimes it's
    also useful to give not the wavelength but the electron volts. Therefore I

    result (h * c/val).ToString()

    in the XScaleFormatEvent. (All physical constants can be looked up in Wiki or
    somewhere else... they are of no further meaning for the scaling task!)

    This is applied to the X2 axis... and there I want to have labels for 1, 1.5,
    2, 2.5 and so on... how can I realize that?

    The X2 axis wavelength values are "delivered" by a curve, that is created in
    accordance to the minimum and maximum wavelength and an electron volt step
    size of at least 0.001 or smaller. (This is due to the fact of the
    1/wavelength, where the stepsize decreases for bigger wavelengths!)

    Hope someone can help me with my problem! If something is not clear, feel free
    to ask!

    Best wishes,


  • Jeff McKim
    Jeff McKim

    It's a little fuzzy since I don't have the complete code context.

    First, what is the symptom of "it doesn't work"? Is the scaling not printing,
    the curve not printing or both; is it something else?

    If I've guessed correctly as to the specifics of the error, I'd guess you have
    a data problem/inconsistency (more in a moment). I'll just say that this is
    maybe the only area where I've found Zed to be a bit weak. Depending on how
    stuck you get, it might be helpful to download the source and step into it.
    I've done this a couple times. It's a little time consuming but it did solve
    one of my problems. The other one was solved somewhere during my 2nd evening

    I don't know what sort of data structure your using, so I'll speak in terms of
    what I'm familiar with, the PointPairList. (I think the general concepts will
    be the same.

    If you're either not displaying data or getting some odd looking results, you
    likely need to inspect the data you're loading to see that it is completely
    contained within the Axis ranges you've specified. Example: Zed was not
    displaying curve or axis data on a graph of mine. Inspection showed that I had
    mismatched some 0 based vs. 1 based arrays. This meant I had a couple 0
    elements that my graph scale was not happy about. Solving for my array
    compatibility issues made my problem vanish.

    Clearly, the downside to Zed in this scenario is the complete disconnect
    between the manifestation of the error viz a vi any error handling, messages
    or information.

    PS. I'm doing wavelength/pixel intensity display with UV/VIS/NIR with ~2nm
    steps, so we're likely talking about similar types of data.


  • Anonymous

    Ok, let's see... first of all: Thanks for your answer... and now I'll try to
    go into detail...

    I'm loading all needed data into ZedGraph as CurveItems (bound to the first
    x-axis). Now I want to set the second x-axis to show the eV values,
    corresponding to the wavelengths on the x-axis. Because of the 1/lambda-
    dependency, the MajorGrid will have decreasing steps, which is (IMHO) not
    possible with ZedGraph. A logarithmic or 1/e scaling won't to either.
    Therefore I tried to build up a workaround.

    If I want to have a scaling of let's say 0.1 eV, I tried to find out, which
    wavelength steps I would need in order to get this (at least) in energy steps.
    Let's say this is reached by 0.2nm steps. I set this as MajorSteps for x2Axis.

    My X2ScaleFormatEvent looks like this:

    double calc = h * c / (valb * Math.Pow(10, -9));
                if ((Math.Floor(calc * 100)/100) == Math.Round(calc, 1))
                    Label = Math.Round(calc, 1).ToString();
                    Label = "";
                return Label;

    With this routine I want label all the grids that have a number like 1.70,
    2.50, 3.10, and so on... this works... a bit... in a range of 1.14 to 2.25 eV
    I'll get 1.3, 1.4, 1.6, 1.7 and 2. (If I'm moving the scale, some values
    vanish and others appear... that's weird...)

    If I'm reducing the MajorSteps (the dLambda), I get empty labels... (though
    they are sometimes filled while moving the scale, as written above)...

    Right now, I don't really know, what to do... Hope you can help me...