I have ~200 points in my line chart and I need to put the calibaration lines in the chart too, so maximal and minimal possible value lines. Right know I’m putting 3 datasets- one with the value, one filled with the minimal and maximal values. Can I somehow draw a line in the chartJS that is not a dataset?

# Tag: axes

## Interpolate on a cylic x axes

Let’s assume you are in 2D space and you have a set of fix points `FIX_POINTS = [(x1, y1), (x2, y2)]`

. I want to interpolate the `y`

value for a given `x`

value using linear interpolation.

Caveat: The x-axis is cyclic, so it wraps around at a certain known value.

I’m searching a neat algorithm (or way to write this down) which can do this interpolation, so take an x value on the cyclic x-axes and compute the y- value using linear interpolation.

Example: Given `FIX_POINTS = [(10, 50), (90, 100)]`

, and a “cyclic interval” (so the value at which the x axes wraps) of `100`

, the interpolation would lead to the following results:

` interpolation(10) = 50 # No interpolation necessary, directly on fix points interpolation(90) = 100 # Same interpolation(50) = 75 # Normal Interpolation interpolation(0) = 75 # Wrap around interpolation interpolation(1) = 72.5 # Same interpolation(99) = 77.5 # Same `

I’m not too curious in the actual programming, I’m searching for a way to write this down nicely. Maybe there is even an existing implementation for this? I’m having troubles asking google for the lack of search terms.

I implemented it myself, but it got a lot of code, so I’m in search of something simpler: https://gist.github.com/theomega/9782be548fd452e1f1469757387b35e4 . This implementation also is far from optimal on the computational side (scanning over the array).

*I’m not sure if this is the stack exchange for this. Feel free to point me in a different direction.*

## Modify Axes Range

With the following code:

`arc = Graphics[{Arrowheads[{0, 0.04}], GraphicsComplex[ Table[{0.5 + 0.7 Re[Exp[I*g]], 0.5 + 0.7 Im[Exp[I*g]]}, {g, Subdivide[0, Pi/2 - Pi/6, 100]}], Arrow[Range[101]]]}]; sensor = Graphics[ Circle[{0.5 + 1. Cos[Pi/3], 0.5 + 1. Sin[Pi/3]}, 0.03]]; sensorM = Graphics[Style[Text["M" , {1, 1.47}], FontSize -> 18, FontFamily -> "Latin Modern Roman"]]; Omega0 = Graphics[ Style[Text[ "\!\(\*SuperscriptBox[\(\[CapitalOmega]\), \(0\)]\)" , {0.2, 1.27}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; OmegaE = Graphics[ Style[Text[ "\!\(\*SuperscriptBox[\(\[CapitalOmega]\), \(e\)]\)" , {0.8, \ -0.27}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; theta = Graphics[ Style[Text["\[Theta]" , {1.2, 0.77}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; rpolar = Graphics[ Style[Text["r" , {0.85, 1.17}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; er = Graphics[ Arrow[{{0.5 + 1. Cos[Pi/3], 0.5 + 1. Sin[Pi/3]}, {0.5 + 1. Cos[Pi/3] + 0.3 Cos[Pi/3], 0.5 + 1. Sin[Pi/3] + 0.3 Sin[Pi/3]}}]]; etheta = Graphics[ Arrow[{{0.5 + 1. Cos[Pi/3], 0.5 + 1. Sin[Pi/3]}, {0.5 + 1. Cos[Pi/3] - 0.3 Sin[Pi/3], 0.5 + 1. Sin[Pi/3] + 0.3 Cos[Pi/3]}}]]; erUnit = Graphics[ Style[Text[Subscript[OverHat[e], r], {1.25, 1.55}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; erthetaUnit = Graphics[Style[Text[Subscript[OverHat[e], \[Theta]], {0.75, 1.65}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; h = Graphics[ Line[{{{-1, 1/2}, {0, 0}, {-1, -1/2}}, {{0, 1/2}, {1, 0}, {0, -1/2}}, {{1, 1/2}, {2, 0}, {1, -1/2}}}]]; propVector = Graphics[{Arrowheads[{{Automatic, Automatic, h}}], Arrow[{{-1., 0.5}, {-0.5, 0.5}}]}]; lines = Graphics[{Line[{{-0.8, 0.2}, {-0.8, 0.8}}], Line[{{-0.75, 0.2}, {-0.75, 0.8}}]}]; pinc = Graphics[ Style[Text["\!\(\*SubscriptBox[\(p\), \(inc\)]\)", {-0.95, 0.75}], FontSize -> 20, FontFamily -> "Latin Modern Roman"]]; Show[{Graphics[{Dotted, Circle[{0.5, 0.5}, 1]}], Graphics[Circle[{0.5, 0.5}, 0.5]], arc, sensor, sensorM, Omega0, OmegaE, theta, rpolar, er, etheta, erUnit, lines, propVector, pinc, erthetaUnit, Graphics[{DotDashed, Arrowheads[0.04], Arrow[{{0.5, 0.5}, {0.5 + 1. Cos[Pi/3], 0.5 + 1. Sin[Pi/3]}}]}]}, Axes -> True, AxesOrigin -> {0.5, 0.5}, AxesLabel -> {Style["x", FontSize -> 20, FontFamily -> "Latin Modern Roman", FontColor -> Black], Style["y", FontSize -> 20, FontFamily -> "Latin Modern Roman", FontColor -> Black]}, AxesStyle -> Arrowheads[{0, 0.05}], PlotRange -> All] `

I produced the following image

Eventually, I will get rid of `AxesTicks`

, but I leave them for reference. I am puzzled how I can modify the Axes Range. For instance, the x-axis should range from -0.3 to 1.3 and similarly for the y-axis. The `AxesLabel`

should be moved accordingly but the rest of the figure should not be modified. Thanks in advance!

## Keyboard shortcuts for separating the zoom-in/out of x and y axes in a chart

Currently, I am working on a plotting library to plot a few charts. most of the charts data vary in the x-dimension too great than y-dimension. ex.

`time x y 0 0 0 1 1 0.0044 2 2 0.0085 `

Currently, we use Ctrl + Wheel to zoom-in/out. It’s good if the values on both axes varies with the same degree, but this is not the case.

I have been thinking about separating the zooming behavior, examples for schemes

### scheme 1

Ctrl + Wheel: both axes.

Ctrl + Shift + Wheel: x-axis.

Ctrl + Alt + Wheel: y-axis.

### scheme 2

Mouse middle button: Switch between axis.

Ctrl + Wheel: zoom the current selected axis or both.

I have been thinking about the schemes, but I don’t think it’s too intuitive.

I have depending on being intuitive for the user interface, as the program itself is very complex with a huge user guide. And I don’t want to add non-necessary documentation for simply navigation.

So is there more intuitive shortcuts for special modes in zooming ?

Thanks

## Scaling the axes in ListDesnsityPlot

I have a matrix of size 800×600 in which each value is basically z value. This matrix is stored in text file. I want to import the file in Mathematica and plot it as DensityPlot using ListDensityPlot. In doing so, I am able to plot the data but the x and y axis scale as 0 to 800 and 0 to 600 respectively indicating basically indices of the values stored in the matrix. But in reality I want to scale both x and y axis lets say x ranges from 0 to 4 and y ranges from 0 to 3. In other words I want to keep full scale of the plot with all the data while my frame ticks on x and y axis scaled from 0 to 4 and 0 to 3 respectively.

For example, when I import the data (here my data is matrix of size 301×201)and plot it, it looks this, here basically it takes x and y axis tick values as data indices in the matrix

But actually, in my plot I want to change the axis tick values like this way keeping everything else as it is