Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6474603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:36:24+00:00 2026-05-25T06:36:24+00:00

I have problems getting Manipulate to work with code assigned to variables that should

  • 0

I have problems getting Manipulate to work with code assigned to variables that should be evaluated inside the Manipulate statement. Here is how it goes …

test1={a,b,c};
Manipulate[test1,{a,0,10,.1},{b,0,10,.1},{c,0,10,.1}]

Manipulate output 1

So {a, b, c} are not updated. Ok, whatever, let’s enforce the evaluation of test1

Manipulate[Evaluate[test1],{a,0,10,.1},{b,0,10,.1},{c,0,10,.1}]

enter image description here

Now it works. But if I want to plot the list of manipulated elements, like this

Manipulate[ListPlot[Evaluate[test1]],{a,0,10,.1},{b,0,10,.1},{c,0,10,.1}]
Manipulate[Evaluate[ListPlot[test1]],{a,0,10,.1},{b,0,10,.1},{c,0,10,.1}]

I end up with

enter image description here

in both chases.

I am aware of ‘Evaluate Expressions inside Dynamic or Manipulate’ in Mathematica’s documentation, but I am pretty sure that it does not provide a solution to my problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:36:24+00:00Added an answer on May 25, 2026 at 6:36 am

    So the problem is that test1 is defined in terms of global variable Global`a,
    but the a defined in the manipulate is created by a DynamicModule and is thus local. This is what acl showed with his Hold[a] example.

    Maybe the easiest way to fix this is to use With to insert test1 into the manipulate:

    Clear[a, b, c]
    test1 = {a, b, c};
    With[{test1 = test1}, 
         Manipulate[test1, {a, 0, 10, .1}, {b, 0, 10, .1}, {c, 0, 10, .1}]]
    

    This way the Manipulate never actually sees test1, all it sees is {a,b,c} which it then goes on to correctly localize. Although, this will run into problems if a,b,c have been given a value before the Manipulate is run – thus the Clear[a,b,c] command.

    I think that the best practice is to make all local variables completely explicit in the manipulate. So you should do something like

    Clear[a, b, c, test1]
    test1[a_, b_, c_] := {a, b, c};
    Manipulate[test1[a, b, c], {a, 0, 10, .1}, {b, 0, 10, .1}, {c, 0, 10, .1}]
    

    This avoids problems with the global vs local variables that you were having. It also makes it easier for you when you have to come back and read your own code again.


    Edit to answer the question in the comments “I really would like to understand why Evaluate does not work with the somewhat nested ListPlot?”. IANLS (I am not Leonid Shifrin) and so I don’t have a perfect Mathematica (non)standard evaluation sequence running in my brain, but I’ll try to explain what’s going on.

    Ok, so unlike Plot, ListPlot does not need to localize any variables, so it does not have the Attribute HoldAll.

    Let’s define something similar to your example:

    ClearAll[a, test]
    test = {a, a + 1};
    

    The final example you gave is like

    Manipulate[Evaluate[ListPlot[test]], {a, 0, 1}]
    

    By looking at the Trace, you see that this first evaluates the first argument which is ListPlot[test] ~> ListPlot[{a,a+1}]
    and since a is not yet localized, it produces an empty list plot. To see this, simply run

    ListPlot[{a, a + 1}]//InputForm
    

    to get the empty graphics object

    Graphics[{}, {AspectRatio -> GoldenRatio^(-1), Axes -> True, AxesOrigin -> {0, 0}, PlotRange -> {{0., 0.}, {0., 0.}}, PlotRangeClipping -> True, PlotRangePadding -> {Scaled[0.02], Scaled[0.02]}}]
    

    As the symbolic values a have been thrown out, they can not get localized by the Manipulate and so not much else happens.

    This could be fixed by still evaluating the first argument, but not calling ListPlot until after Manipulate has localized the variables. For example, both of the following work

    Manipulate[Evaluate[listPlot[test]], {a, 0, 1}] /. listPlot -> ListPlot
    Manipulate[Evaluate[Hold[ListPlot][test]], {a, 0, 1}] // ReleaseHold
    

    The fact that ListPlot throws away non-numeric values without even the slightest complaint, is probably a feature, but can lead to some annoyingly hard to track bugs (like the one this question pertains to). Maybe a more consistent (but less useful?) behaviour would be to return an unevaluated ListPlot if the plot values are non-numeric… Or to at least issue a warning that some non-numeric points have been discarded.

    The penultimate example you gave is (more?) interesting, it looks like

    Manipulate[ListPlot[Evaluate[test]], {a, 0, 1}]
    

    Now since Manipulate has the attribute HoldAll, the first thing it does is wrap the arguments in Hold, so if you look at the Trace, you’ll see Hold[ListPlot[Evaluate[test]]] being carried around. The Evaluate is not seen, since as described in the Possible Issues section, “Evaluate works only on the first level, directly inside a held function”. This means that test is not evaluated until after the variables have been localized and so they are taken to be the global a and not the local (DynamicModule) a.

    It’s worth thinking about how the following variations work

    ClearAll[a, test, f, g]
    SetAttributes[g, HoldAll];
    test = {a, a + 1};
    
    Grid[{
      {Manipulate[test, {a, 0, 1}], Manipulate[Evaluate[test], {a, 0, 1}]},
      {Manipulate[f[test], {a, 0, 1}], 
       Manipulate[f[Evaluate[test]], {a, 0, 1}]},
      {Manipulate[g[test], {a, 0, 1}], 
       Manipulate[g[Evaluate[test]], {a, 0, 1}]}
      }]
    

    brainpain

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to code up an Emacs script that has to manipulate the clipboard
I have some problems with getting my website to log out the authenticated user
I am having problems getting Microsoft Charting: System.Web.DataVisualization.dll To work in the Medium Trust
I am having problems getting a function that clicks all search matched checkboxes. The
I have some problems getting the custom formated JSON data into a dijit.form.FilteringSelect. It
I have problems getting a JQuery Edit-In-Place textarea to be a fixed size. Basically
I have problems getting two Textviews to behave the way I want. I want
I've made a website using Flask and I have no problems getting things to
I have a problem regarding getting the path of a user control. The scenario
I have problems with bringing a windows mobile 6 form to the front. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.