Plotting Multiple values on different domains

In summary, the conversation is about plotting a list of numbers on a 1-unit long interval and generating plots on the same axes. The solution is to use a table and the "Show" function, and you can add a plot legend by including it in the plot command.
  • #1
member 428835
Hi PF!

I have a list of numbers, and I'm trying to plot each constant value on a 1-unit long interval. What I'm trying is this

Code:
a = Table[i, {i, 2, 8}];
For[i = 1, i < 5, i++, Plot[a[[i]], {x, i - 1, i}] // Print]

but that generates plots that are not on the same axes. Any help?
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
I have edited your post to put the Mathematica code inside code tags. Otherwise, it doesn't come out properly.

What you need to do is to generate the plots inside a table, and then use Show to plots all of them on the same graph:
Code:
Show[Table[Plot[a[[i]], {x, i - 1, i}], {i, 1, 4}], PlotRange -> {{0, 4}, {0, 6}}]
 
  • Like
Likes member 428835
  • #3
DrClaude said:
I have edited your post to put the Mathematica code inside code tags. Otherwise, it doesn't come out properly.

What you need to do is to generate the plots inside a table, and then use Show to plots all of them on the same graph:
Code:
Show[Table[Plot[a[[i]], {x, i - 1, i}], {i, 1, 4}], PlotRange -> {{0, 4}, {0, 6}}]
Hey thanks! so if I have ##a## and ##b##, do you know how to create a plot legend, because when I add PlotLegends inside the table I obviously get 4 legends? If statement or is there a better way?
 
Last edited by a moderator:
  • #4
You can add a PlotLegend in the Plot, e.g,
Code:
Show[Table[
  Plot[a[[i]], {x, i - 1, i}, PlotLegends -> {i}], {i, 1, 4}], PlotRange -> {{0, 4}, {0, 6}}]
 

1. How can I plot multiple values on different domains in one graph?

To plot multiple values on different domains in one graph, you can use a technique called "overlaying". This involves plotting each set of values on its own axis and then superimposing them on top of each other. This can be done using specialized software or programming languages like Python or R.

2. Can I plot multiple values on different domains using Excel?

Yes, you can plot multiple values on different domains using Excel. You can achieve this by using the "Combo Chart" feature, which allows you to combine different types of charts on one graph. You can also use the "Secondary Axis" feature to plot values on different domains on the same graph.

3. How do I choose the right scale for each domain when plotting multiple values?

The scale for each domain will depend on the range of values for that particular set of data. It is important to choose a scale that accurately represents the data and is easy to interpret. You can use logarithmic scales for data with a large range of values, and linear scales for data with smaller ranges.

4. Can I plot multiple values on different domains using a bar graph?

Yes, you can plot multiple values on different domains using a bar graph. However, it may not be the most effective way to display this type of data as it can become cluttered and difficult to interpret. Line graphs or scatter plots may be better options for plotting multiple values on different domains.

5. How can I ensure that the different domains are clearly labeled on the graph?

To ensure that the different domains are clearly labeled on the graph, you can use a legend or axis labels. The legend can indicate which color or symbol represents which domain, while the axis labels can clearly show the values for each domain. It is important to make sure these labels are legible and easy to understand.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
745
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
261
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
696
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top