天道酬勤,学无止境

Plotly + Julia + Latex

I would like to use latex with the Plotly backend. Look in this example: Even the x-axis and y-axis log scales are not formatted properly! Do you know how to do that?

Best,

v.

using Plots, LaTeXStrings
plotlyjs()
x =  10 .^ LinRange(-5,5,10)

plot(x, 1 ./ x, yaxis=:log, xaxis=:log, m = 2, xlabel="x", label="1/x",ylabel="f(x)")
plot!(x, 10 ./ x, m=2,label="10/x")
plot!(x, 1 ./ (x.^2), m=2, label=L"f(x)=$1/x^2$")
savefig("./test.png")

评论

Seems to work with the gr() backend, so I expect LaTeXString is not supported by the plotlyjs() backend.

受限制的 HTML

  • 允许的HTML标签:<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • 自动断行和分段。
  • 网页和电子邮件地址自动转换为链接。

相关推荐
  • Scaling plotly figures in knitr Latex document
    I'm trying to include a plotly chart into a Latex document with knitr. Since knitr includes the webshot package this works well. But if I want to resize my figure for the latex output, the figure environment gets bigger but the plotly chart is not scalled to the manually set figure width and height. Specifing the webshot options like recommend here, did not work neither. Scaling a ggplot chart works well, but how can I get the same results for the plotly chart? \documentclass{article} \usepackage{cleveref} <<setup, echo=FALSE, message = FALSE, warning = FALSE>>= library(ggplot2) library(plotly
  • Julia: docstrings and LaTeX
    Julia has docstrings capabilities, which are documented here https://docs.julialang.org/en/stable/manual/documentation/. I'm under the impression that it has support for LaTeX code, but I'm not sure if the intention is that the LaTeX code should look like code or like an interpretation. In the following, the LaTeX code is garbled somewhat (see rho, for instance) and not interpreted (rho does not look like ρ). Am I doing something wrong? Is there a way to get LaTeX code look interpreted? What I mean by interpreted is something like what they do at https://math.stackexchange.com/. The
  • How to plot a vector field in Julia?
    I want to plot a vector field in Julia. I could not find an example here. Here there are some examples using plotly, however, they do not work for me. I would like to plot the vector field by plotlyjs or plotly. Here is an example code in Julia: using Plots pyplot() x = collect(linspace(0,10,100)); X = repmat(x,1,length(x)); Y = repmat(x',length(x),1); U = cos.(X.*Y); V = sin.(X.*Y); streamplot(X,Y,U,V) Here is the Matlab example: [x,y] = meshgrid(0:0.2:2,0:0.2:2); u = cos(x).*y; v = sin(x).*y; figure quiver(x,y,u,v)
  • 在 knitr/rmarkdown 中绘制为 png(Plotly as png in knitr/rmarkdown)
    问题 下面的 Rmarkdown 在 HTML 中呈现可绘制的 3D 图形,但不是在 PDF 中。 Testing plotly ```{r} library(plotly) p <- plot_ly(data=iris, x=~Sepal.Length, y=~Sepal.Width, z=~Petal.Length, color=~Species, symbols=c(0,1), type="scatter3d", mode="markers") p ``` 图形的快照如下所示: 根据情节帮助页面: 如果您将 rmarkdown 与 HTML 输出一起使用,则在代码块中打印绘图对象将产生交互式 HTML 图形。 将 rmarkdown 与非 HTML 输出一起使用时,打印 plotly 对象将生成图形的 png 屏幕截图。 有没有办法在 PDF 中渲染绘图? 注意:来自rmarkdown::render()的错误是: Error: Functions that produce HTML output found in document targeting latex output. Please change the output type of this document to HTML. Alternatively, you can allow HTML output in
  • Plotly as png in knitr/rmarkdown
    The following Rmarkdown renders the plotly 3D graph in HTML, but not in PDF. Testing plotly ```{r} library(plotly) p <- plot_ly(data=iris, x=~Sepal.Length, y=~Sepal.Width, z=~Petal.Length, color=~Species, symbols=c(0,1), type="scatter3d", mode="markers") p ``` A snapshot of the graph appears as follows: According to the plotly help page: If you are using rmarkdown with HTML output, printing a plotly object in a code chunk will result in an interactive HTML graph. When using rmarkdown with non-HTML output, printing a plotly object will result in a png screenshot of the graph. Is there a way to
  • 如何使用户定义的函数描述(“文档字符串”)可用于 julia REPL?(How to make user defined function descriptions (“docstrings”) available to julia REPL?)
    问题 当使用?f或help(f)通过 REPL 检查时,用户定义的函数(例如f )如何具有有意义的打印输出 例如,想象我写了以下功能 function f(x::Float64, y::Float64) return 2x - y^2 end 如果我将其加载到 julia 会话中并尝试help(f)我得到以下信息: julia> help(f) f (generic function with 1 method) 如果我想看到类似的东西怎么办 julia> help(f) f Compute 2 times x minus y squared 其中描述“计算 2 次 x 减去 y 平方”写在某处。 我猜我的问题的答案可以从“描述应该写在哪里的地方?”这个问题的答案中确定。 举例来说,如果我想在 python 中做同样的事情,我可以定义函数并将描述作为文档字符串: def f(x, y): """ Compute 2 times x minus y squared """ return 2 * x - y ** 2 当我输入help(f)或f?时,这将使我的描述立即可用f? 来自 IPython。 回答1 您可以在 Julia 版本 0.4(2015 年 10 月)及更高版本中使用 @doc 宏。 % julia _ _ _ _(_)_ | A fresh approach to
  • 在 Julia 中插入时如何格式化字符串?(How do you format a string when interpolated in Julia?)
    问题 在 Python 3 中,我会 print_me = "Look at this significant figure formatted number: {:.2f}!".format(floating_point_number) print(print_me) 或者 print_me = f"Look at this significant figure formatted number: {floating_point_number:.2f}!" print(print_me) 在朱莉娅 print_me = "Look at this significant figure formatted number: $floating_point_number" print(print_me) 但这会产生说 Look at this significant figure formatted number: 61.61616161616161 我如何让 Julia 限制它显示的小数位数? 请注意,据我所知,要打印的字符串的必要存储排除了使用@printf宏的@printf 。 这有效,但在风格上似乎不正确。 floating_point_number = round(floating_point_number,2) print_me = "Look at this
  • string variable as latex in pyplot
    It is possible to have Latex formatting in pyplot diagrams, i.e. for title, labels etc. #some dummy code plt.plot(x,y,label = r"$a < \gamma$") It is generated by adding an r before the actual latex string. Now, pyplot accepts variables as inputs for strings, i.e. #some dummy code foo = "some fancy label" plt.plot(x,y, label = foo) I would like to combine the two worlds, however the only answer I found on SO is for Julia. How can I make this work?
  • PDF 中的 Pandoc 语法突出显示不起作用(Pandoc Syntax Highlighting in PDF not working)
    问题 pandoc --version产生: pandoc 1.12.2.1 Compiled with texmath 0.6.5.2, highlighting-kate 0.5.5.1. Syntax highlighting is supported for the following languages: actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang, fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc, javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell, lua, makefile, mandoc, markdown, matlab, maxima, metafont, mips
  • 碾压Python!为什么Julia速度这么快?
    什么要选择 Julia?因为它比其他脚本语言更快,它在具备 Python、MATLAB、R 语言开发速度的同时,又能生成与 C 语言和 Fortran 一样快的代码。但 Julia 新手对这种说法可能会有点怀疑。 为什么其他脚本语言不也提升一下速度?Julia 可以做到的,为什么其他脚本语言做不到?你能提供基准测试来证明它的速度吗?这似乎有违“天底下没有免费的午餐”的道理。它真的有那么完美吗?很多人认为 Julia 运行速度很快,因为它是即时编译(JIT)型的(也就是说,每条语句都使用编译的函数来运行,这些函数要么在使用之前进行即时编译,要么在之前已经编译过并放在缓存中)。这就引出了一个问题:Julia 是否提供了比 Python 或 R 语言(MATLAB 默认使用 JIT)更好的 JIT 实现?因为人们在这些 JIT 编译器上所做的工作比 Julia 要多得多,所以我们凭什么认为 Julia 这么快就会超过这些编译器?但其实这完全是对 Julia 的误解。我想以一种非常直观的方式说明,Julia 的速度之所以快,是因为它的设计决策。Julia 的的核心设计决策是通过多重分派实现专门化的类型稳定性,编译器因此可以很容易地生成高效的代码,同时还能够保持代码的简洁,让它“看起来就像一门脚本语言”。但是,在本文的示例中,我们将看到 Julia 并不总是像其他脚本语言那样,我们必须接受
  • Pandoc Syntax Highlighting in PDF not working
    pandoc --version yields: pandoc 1.12.2.1 Compiled with texmath 0.6.5.2, highlighting-kate 0.5.5.1. Syntax highlighting is supported for the following languages: actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang, fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc, javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell, lua, makefile, mandoc, markdown, matlab, maxima, metafont, mips
  • Getting some problems with pandoc and mathjax
    I'm trying to use pandoc to produce a html slideshow from a markdown file with some latex in it. The file is here at github. If I run the following pandoc command: pandoc -s -t s5 --mathjax apresentacao.md -o index.html The math is perfectly displayed by MathJax, but I only get a webpage with all the slides and no slideshow functionality. If I run the follwing command: pandoc -s --self-contained -t s5 --mathjax apresentacao.md -o index.html I get a perfectly alright presentation, but MathJax fails to load. The resulting html file is (undestandably) full of binaries in it, for the images and
  • How do I remove empty space between code chunks in Rmd output to PDF?
    How do I remove the extra empty space between the end of a chart and the next one? I have a shiny app that runs a parameterized .Rmd that outputs to both html and PDF. The html is fine, but there is too much white space in the PDF. I am supposed to fit everything in two pages (hence the squishy margins/geometry), but the text I need to add at the bottom of page 1 doesn't fit AND inserts a blank first page. There is space between my charts, and if I could remove it, everything would probably fit. (The layout is done in a table for html (as I have too much going on to figure out how to do that
  • 使用 pandoc 和 mathjax 时遇到一些问题(Getting some problems with pandoc and mathjax)
    问题 我正在尝试使用 pandoc 从 Markdown 文件中生成一个 html 幻灯片,其中包含一些乳胶。 该文件在 github 上。 如果我运行以下 pandoc 命令: pandoc -s -t s5 --mathjax apresentacao.md -o index.html MathJax 完美地显示了数学,但我只得到一个包含所有幻灯片的网页,没有幻灯片功能。 如果我运行以下命令: pandoc -s --self-contained -t s5 --mathjax apresentacao.md -o index.html 我得到了一个完美的演示文稿,但 MathJax 无法加载。 生成的 html 文件(不可理解地)充满了二进制文件,用于加载的图像和 javascript 库。 但它似乎没有正确地合并 MathJax。 各位有这个问题吗? 有什么简单的方法可以解决这个问题吗? 我正在使用以下 pandoc 版本: $ pandoc --version pandoc 1.11.1 Compiled with citeproc-hs 0.3.8, texmath 0.6.1.3, highlighting-kate 0.5.3.8. Syntax highlighting is supported for the following languages
  • Awesome R:资源汇总
    Awesome R Awesome R 202020192018Integrated Development EnvironmentsSyntaxData ManipulationGraphic DisplaysHtml WidgetsReproducible ResearchWeb Technologies and ServicesParallel ComputingHigh PerformanceLanguage APIDatabase ManagementMachine LearningNatural Language ProcessingBayesianOptimizationFinanceBioinformatics and BiostatisticsNetwork AnalysisSpatialR DevelopmentLoggingData PackagesOther ToolsOther InterpretersLearning R Resources WebsitesBooksPodcastsReference CardsMOOCsLists Other Awesome ListsContributing 2020 VSCode - vscode-R + vscode-r-lsp VSCode R Langauage Supportgt - Easily
  • Python相关实用技巧03:14个对数据科学最有用的Python库
    Python相关实用技巧03:14个对数据科学最有用的Python库 1 Pandas2 NumPy3 SciPy4 Matplotlib5 Seaborn6 Plotly7 Scikit Learn8 TensorFlow9 Keras10 Statsmodels11 Spacy12 Bokeh13 Gensim14 NLTK Python一直以来都是数据科学家的宠儿。与云计算、大数据、人工智能、物联网和区块链等领域,特别是人工智能领域,以及数据科学领域的人交流得越多,就会发现熟练掌握Python的重要性。 话虽如此,当人们开始学习Python技能时,必须先了解Python库的重要列表。数据科学专业的人们肯定知道那些可以用于数据科学领域的 Python库,但是在面试中被问及它们的名称或者说明它的功能时,我们可能记不住超过5个库。 这里精选了14个 Python库,它们可以帮助数据科学研究或项目,包括什么时候使用它们,它们的重要特性和优点是什么。下面简要介绍14个对于数据科学家和工程师来说最有用的Python库。 1 Pandas Pandas是一个开源的Python包,它为标签数据提供了高性能、易于使用的数据结构和数据分析工具。Pandas代表Python数据分析库,Pandas是处理数据的完美工具。它用于快速和简单的数据操作、读取、聚合和可视化。
  • R doesn't recognize Pandoc Linux Mint
    I asked a related question: check if a program is installed But am refraining from answering until I've tested the solutions for myself on all three systems. I can get pandoc to work from within R on a windows machine but on linux I get this error/response for each method from the R terminal: 1: > system('pandoc -v') sh: 1: pandoc: not found 2: > myPaths <- c("pandoc", + "~/.cabal/bin/pandoc", + "~/Library/Haskell/bin/pandoc", + "C:\\PROGRA~1\\Pandoc\\bin\\pandoc") > Sys.which(myPaths) pandoc ~/.cabal/bin/pandoc "" "/home/tyler/.cabal/bin/pandoc" ~/Library/Haskell/bin/pandoc C:\\PROGRA~1\
  • Google colaboratory的Plotly Notebook模式(Plotly notebook mode with google colaboratory)
    问题 我正在尝试使用plotly笔记本模式进行协作-我打开一个新的笔记本,从plotly的文档中复制并粘贴以下简单示例,但看不到输出。 通常情况下,输出空间中会有一个很大的空白。 这在我的本地笔记本上工作正常(这是plotly的较新版本,但根据他们的文档离线模式,该版本应与google colab版本一起使用)有什么想法吗? import plotly from plotly.graph_objs import Scatter, Layout plotly.offline.init_notebook_mode(connected=True) plotly.offline.iplot({ "data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])], "layout": Layout(title="hello world") }) 回答1 plotly版本4.x 从版本4开始, plotly渲染器了解Colab,因此以下内容足以在Colab和Jupyter(以及其他笔记本,如Kaggle,Azure,nteract)中显示图形: import plotly.graph_objects as go fig = go.Figure( go.Scatter(x=[1,2,3], y=[1,3,2] ) ) fig.show() plotly版本3.x
  • 在Julia中更改软件包目录(Change Package directory in Julia)
    问题 我想在Julia中更改Package目录。 默认是 "~/.julia/v0.4" 我想将其移动到/opt/julia/v0.4/ 。 理想情况下,我想将~/.julia/v0.4中已经安装的软件包移到新位置。 但是,如果那不可能,我可以重新安装它们。 我需要做什么? 回答1 Julia-v0.6及更低版本 可以按照以下步骤更改julia的软件包目录: 在shell中运行export JULIA_PKGDIR=/your/directory (或在Windows上手动添加新的环境变量JULIA_PKGDIR ) 在julia中运行Pkg.init()以初始化新的软件包系统将REQUIRE从旧目录复制到新目录在julia中运行Pkg.resolve() 朱莉娅v0.7 + 新软件包管理器中的“软件包目录”称为DEPOT_PATH,可以通过添加环境变量JULIA_DEPOT_PATH来更改它: JULIA_DEPOT_PATH=./test julia julia> DEPOT_PATH 1-element Array{String,1}: "./test" (v0.7) pkg> add JSON2 Cloning default registries into /Users/gnimuc/test/registries 使用新的软件包管理器
  • Plotly import error for exceptions module
    I have searched all over and couldn't find the solution to this problem. I am trying to import plotly in Jupyter Notebook with following code and getting the following error respectively Code: import sys print(sys.path) sys.path.append('/usr/local/lib/python2.7/dist-packages') import plotly Error: --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-3-b41540b5e198> in <module>() 3 sys.path.append('/usr/local/lib/python2.7/dist-packages') 4 ----> 5 import plotly /usr/local/lib/python2.7/dist-packages/plotly/_