Hot answers tagged

7

I would advocate using the pgfplots package for this type of graphic. It allows you to use the following, for example \begin{tikzpicture} \begin{axis} \addplot[timtam]expression[domain=-3.5:3.5]{sin(x)}; \end{axis} \end{tikzpicture} Here's a couple of demonstrations; adjust as you see fit. For reference, see also Axis with trigonometric ...


6

LuaLaTeX has an integrated JSON parser. With some wrapper code around \pgfplotstableread this can be used to read from a JSON file directly into a pgfplots table. \begin{filecontents*}{test.json} { "name":"list_of_xy_values", "data":[[1,2],[2,4],[3,6],[4,3],[5,0]] } \end{filecontents*} \documentclass{article} \...


5

You're not passing Lua results to TeX. You have to use tex.sprint (see this question by Henri Menke for some ideas and common mistakes). I won't discuss your approach to factorials, but I think you should use locals in Lua functions: \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=newest} \usepackage{luacode} \begin{luacode*} function ...


2

You could try something like this, with pgfplots: \documentclass[border=2mm]{standalone} \usepackage {pgfplots} \pgfplotsset{compat=1.17} \def\func(#1){0.75*#1+0.58} % Linear regression function \pgfmathsetmacro\y{\func(2)} % \alpha x_1 + \beta \begin{document} \begin{tikzpicture}[line cap=round, mark options={mark size=1.5pt,fill=white}] \begin{...


1

The problem is that the \addplot commands are accumulated in the loop, with \m still unexpanded. When the plots are finally drawn, the current value of \m is used, which is its last one, 100.0. You can put the loop body into a macro: \newcommand\myplot[2]{%#1 = color mix, #2 = plot parameter \addplot[blue!#1!red] {(3-#2)/4*x^2+(#2-2)*x+1} node[pos=.55,...


Only top voted, non community-wiki answers of a minimum length are eligible