gnuplot plot xy cspline with data points in order - time-series

Here is a minimum example:
set xrange [31:42]
set yrange [3.5:6.5]
set nokey
plot "-" using 2:3 smooth cspline
2015 34 4
2016 41 5
2017 40 6
2018 32 6
The result looks nice but ignores the time series:
minimal example using splot instead of plot:
set view map
splot "-" using 2:3:1 with line
2015 34 4
2016 41 5
2017 40 6
2018 32 6
The result is correct but does not look nice:
How can I smooth this as in the first example?

My solution: Make gnuplot output a complex graph without this troublesome non-monotonic curve to a LaTeX2e picture, draw this curve separately using the LaTeX2e TikZ package, and edit the picture to include the curve in the correct position and scale.
\addplot[smooth] coordinates {
(34,4)
(41,5)
(40,6)
(32,6)
}

Related

Gnuplot filled curves adds unwanted "bottom" border

I am trying to visualize a time series data set on one plot as a pseudo 3d figure. However, I am having some trouble getting the filledcurves capability working properly. It seems to be adding an unwanted border at the "bottom" of my functions and I do not know how to fix this.
This is my current set up: I have nb_of_frames different files that I want to plot on one figure. Without the filledcurves option, I can do something like this
plot for [i=1:nb_of_frames] filename(i) u ($1):(50.0 * $2 + (11.0 - (i-1)*time_step)) w l linewidth 1.2 lt rgb "black" notitle
which produces a figure like this:
no fill options
Instead of doing this, I want to use the filledcurves option to bring my plots "forward" and highlight the function that is more "forward" which I try to do with:
plot for [i=1:nb_of_frames] filename(i) u ($1):(50. * $2 + (11. - (i-1)*time_step)) w filledcurves fc "white" fs solid 1.0 border lc "black" notitle
This produces a figure as follows:
This is very close to what I want, but it seems that the border option adds a line underneath the function which I do not want. I have tried several variants of with filledcurves y1=0.0 with different values of y1, but nothing seems to work.
Any help would be appreciated. Thank you for your time.
Here is another workaround for gnuplot 5.2.
Apparently, gnuplot closes the filled area from the last point back to the first point. Hence, if you specifiy border, then this line will also have a border which is undesired here (at least until gnuplot 5.4rc2 as #Ethan says).
A straightforward solution would be to plot the data with filledcurves without border and then again with lines. However, since this is a series of shifted data, this has to be plotted alternately. Unfortunately, gnuplot cannot switch plotting styles within a for loop (at least I don't know how). As a workaround for this, you have to build your plot command in a previous loop and use it with a macro # (check help macros) in the plot command. I hope you can adapt the example below to your needs.
Code:
### filledcurves without bottom border
reset session
set colorsequence classic
$Data <<EOD
1 0
2 1
3 2
4 1
5 4
6 5
7 2
8 1
9 0
EOD
myData(i) = sprintf('$Data u ($1-0.1*%d):($2+%d/5.)',i,i)
myFill = ' w filledcurves fc "0xffdddd" fs solid 1 notitle'
myLine = ' w l lc rgb "black" notitle'
myPlotCmd = ''
do for [i=11:1:-1] {
myPlotCmd = myPlotCmd.myData(i).myFill.", ".myData(i).myLine.", "
}
plot #myPlotCmd
### end of code
Result:
I can reproduce this in gnuplot 5.2.8 but not in the output from the release candidate for version 5.4. So I think that some bug-fix or change was applied during the past year or so. I realize that doesn't help while you are using verion 5.2, but if you can download and build from source for the 5.4 release candidate that would take care of it.
Update
I thought of a work-around, although it may be too complicated to be worth it.
You can treat this as a 2D projection of a 3D fence plot constructed using plot style with zerrorfill. In this projection the y coordinate is the visual depth. X is X. Three quantities are needed on z: the bounding line, the bottom, and the top. I.e. 5 fields in the using clause: x depth zline zbase ztop.
unset key
set view 90, 180
set xyplane at 0
unset ytics
set title "3D projection into the xz plane\nplot with zerrorfill" offset 0,-2
set xlabel "X axis" offset 0,-1
set zlabel "Z"
splot for [i=1:25] 'foo.dat' using ($1+i):(i/100.):($2-i):(-i):($2-i) \
with zerrorfill fc "light-cyan" lc "black" lw 2

mapping highlights/annotations to text in pdf

So i have this sample pdf file with three words on separate lines:
"
hello
there
world
"
I have highlighted the word "there" on the second line. Internally, within the pdf, i'm trying to map the highlight/annotation structure to the text (BT) area.
The section corresponding to the word "there" looks like so:
BT
/F0 14.6599998 Tf
1 0 0 -1 0 130 Tm
96 0 Td <0057> Tj
4.0719757 0 Td <004B> Tj
8.1511078 0 Td <0048> Tj
8.1511078 0 Td <0055> Tj
4.8806458 0 Td <0048> Tj
ET
I also have an annotation section where I have my highlight which has the following rect dimensions:
18 0 19 15 20 694 21 786 22 853 23 1058 24 1331 [19 0 R 20 0 R]<</AP<</N 10 0 R>>
...
(I left the top part of the annotation out on purpose because it is long. I extracted what i thought were the most important parts.
Rect[68.0024 690.459 101.054 706.37]
I'm kind of confused about how my text is mapped to this one highlight that I have. The coordinates do not seem to match (130 y vs 690 y)? Am I looking in the right place and interpreting my text and/or highlight annotation coordinates correctly?
Update:
i want to add more info on how I created this test pdf.
Its pretty simple to recreate the pdf. I went to google docs and created an empty document. On three lines i wrote my text as described above. I downloaded that as a pdf and then opened it in adobe acrobat reader DC (the newest one i think). I then used adobe acrobat reader to highlight the specified line and re save it. After that I used some python to unzip the pdf sections.
The python code to decompress the pdf sections:
import re
import zlib
pdf = open("helloworld.pdf", "rb").read()
stream = re.compile(r'.*?FlateDecode.*?stream(.*?)endstream', re.S)
for s in stream.findall(pdf):
s = s.strip('\r\n')
try:
print(zlib.decompress(s))
print("")
except:
pass
Unfortunately the OP only explained how he created his document and did not share the document itself. I followed his instructions but the coordinates of the annotation differ. As I only have this document for explanation, though, the OP will have to mentally adapt the following to the precise numbers in his document.
The starting coordinate system
The starting (default) user coordinate system in the document is implied by the crop box. In the document at hand the crop box is defined as
/CropBox [0 0 596 843]
i.e. the visible page is 596 units wide and 843 units high (given the default user unit of 1/72" this is an A4 format) and the origin is in the lower left corner. x coordinates increase to the right, y coordinate increase upwards. Thus, a coordinate system as usually started with in math, too.
The annotation rectangle
This also is the coordinate system of the annotation rectangle coordinates.
In the case at hand they are
/Rect [68.0595 741.373 101.138 757.298]
i.e. the rectangle with the lower left corner at (68.0595, 741.373) and the upper right at (101.138, 757.298).
Transformations of the coordinate system
In the page content stream up to the text object already identified by the OP the coordinate system gets transformed a number of times.
Mirroring, translation
In the very first line of the page content
1 0 0 -1 0 843 cm
This transformation moves the origin up by 843 units and mirrors (multiplies by -1) the y coordinate.
Thus, now be have a coordinate system with the origin in the upper left and y coordinate increasing downwards.
Scaling
A bit later in the content stream the coordinate system is scaled
.75062972 0 0 .75062972 0 0 cm
Thus, the coordinate units are compressed to about 3/4 of their original width and height, i.e. each unit along the x or y is only 1/96" wide/high.
The text "there"
Only after these transformations have been applied to the coordinate system, the text object identified by the OP is drawn. It starts by setting and changing the text matrix:
1 0 0 -1 0 130 Tm
This sets the text matrix to translate by 130 units in y direction and mirroring y coordinates once again. (Mirroring back again is necessary as otherwise the text would be drawn upside down.)
96 0 Td
This changes the text matrix by moving 96 units along the x axis.
And the starting point where the text is drawn is at the origin of the coordinate system first changed by the mirroring and translation, and then by scaling of the current transformation matrix, and then by mirroring and translation according to the text matrix.
Does it match?
Which coordinate would this point be in the default user coordinate system?
x = (0 + 96) * .75062972 = 72 (approximately)
y = (((0 * (-1)) + 130) * .75062972) * (-1) + 843 = 745,4 (approximately)
This matches with the annotation rectangle (see above) with x coordinates between 68.0595 and 101.138 and y coordinates between 741.373 and 757.298.
So
I'm kind of confused about how my text is mapped to this one highlight that I have. The coordinates do not seem to match (130 y vs 690 y)? Am I looking in the right place and interpreting my text and/or highlight annotation coordinates correctly?
The coordinates do match, you merely have to make sure you apply the transformations of the current transformation matrix and the text matrix.

Want to set label value on TeeChart InnerTick VC++

I wanted to set label text value on TeeChart InnerTick using VC++. like we have below example (I wanted to set AAAA,BBBB,CCCC,DDDD values).
// Sorry i was not able to attach image.
Below mention chart we have created using CGraph. to get co-ordinates we are using SDKInfo property. i wanted to know that how can we get all these x axis,y axis values using TeeChart. Is there any API to get these co ordinates ?
1
X axis max (your data units)
2
X axis min (your data units)
3
Y axis max (your data units)
4
Y axis min (your data units)
5
X axis length (Graphics Server view units)
6
Y axis length (Graphics Server view units)
7
X origin (Graphics Server view units)
8
Y origin (Graphics Server view units)
9
Label font size (percentage of system font)
|
|
| AAAA BBBB CCC DDDD
|__________|____________________|___________________|__________________|________
| | | |
111 222 333 444
Thanks,
I'm not sure about what exact TeeChart version are you using so this answer may be a bit vague.
All binary installations of TeeChart come with a program we call "Features Demo". This program includes examples showing how to use the majority of features supported.
One of the examples is the "Custom Labels", you should find it under "All Features\Welcome !\Axes\Labels\Custom Labels" in the program.
Also, to convert axis values to screen pixels, all TeeChart versions provide "Calc*" functions for it. Ie, to convert the value 10 in the bottom axis to pixels, in TeeChart ActiveX:
XPix = tChart1.Axis.Bottom.CalcXPosValue(10);
Just note these functions need the chart to be drawn once so the internal properties have been initialized and the calculations can be correctly done.

highcharts not to fill the width

I am using highcharts to draw a stock graph. It start with zero data, then add one data point per minute. after whole day, it fill with 240 data points.
The x axis is fix length, and designed for the whole 240 data points. When the data points have not grow to 240 yet, we want the corresponding part of chart of the missed data to be empty.
I've check the highcharts API, and cannot find options to do that. It looks like all the highcharts demo are filled the chart with data available.
thanks!
In short, you set xAxis.min and xAxis.max.
For example if you have two points in your data:
// January 1st 2015, 00:00 and 00:01
data : [[1420070400000, 3], [1420070460000, 7]]
Then you'd set the min and max to allow space for all the points that will eventually be added:
xAxis: {
min: 1420070400000,
max: 1420070400000 + 86400000 // 60 * 60 * 24 * 1000 added
}
As in this demonstration, which has two points and space for the entire day.

The ex unit is not proportional on iOS

I have noticed this strange issue on iOS.
On jsFiddle, 1ex equals 7px. You would assume that 10ex would be 70px. But it is actually 71px!
jsFiddle
The output on iOS7 iPad:
7 // 1ex in px
14
21
28
35
42
50
57
64
71 // 10ex in px
On Chrome and IE11, I confirmed that they are proportional.
I used getBoundingClientRect() so these values shouldn't be rounded. But the only reason I can think of is that they are indeed rounded values. Is this a bug?
I hope it is not "just because that's how the browser works". Because of this inconsistency, I'm having trouble calculating width of some components.

Resources