GithubHelp home page GithubHelp logo

Comments (3)

drgrice1 avatar drgrice1 commented on August 20, 2024

This is technically not a bug, but an unimplemented feature. There is no special handling for passing a MathObject to TikZ in this manner. What is happening is that the MathObject formula is interpolated into the string via MathObject stringification. That will most likely cause problems in quite a few scenarios as MathObject stringification isn't designed to produce what the pgfplots package needs.

from pg.

Alex-Jordan avatar Alex-Jordan commented on August 20, 2024

Glenn is right and in general we want to be aware of things like brackets and any other thing that could be in MathObjects string output that is not good for whatever latex image-making tool is being used. The feature to use tikz in WeBWorK problems did not come with a promise that \addplot {$f}; would always work.

One thing you can do is Context()->flags->set(showExtraParens => 0);. This will reduce instances of nested grouping symbols. In your case, it leads to 0.1*(x--1)*(x--2)*(x-4) which pgfplots has no problem with.

In this particular case, you can also use reduce like:

$f=Formula("$a*(x-$r)*(x-$s)*(x-$t)")->reduce;

leading to 0.1*(x+1)*(x+2)*(x-4) which is of course also good.

from pg.

sean-fitzpatrick avatar sean-fitzpatrick commented on August 20, 2024

Thanks. I guess this became less of a bug report and more of a feature request. But simply reducing first would help here (and is probably good practice in any case).

Other pitfalls will likely require manual entry of functions into TikZ: e.g. domain for trig functions needs to be converted to degrees.

from pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.