I want to express y(x) with ListPlot so that x is expressed as I wish instead of just integers. The only way I know is ListPlot[Table[{10i,20i},{i,1,5}]]. But sometimes one wants to define x and y separately in ListPlot. For example I already have x as


How to define y in a separate command as ListPlot[Table[20i,{i,1,5}]] and show the result as ListPlot[Table[{10i,20i},{i,1,5}]]? In other words, I don't want x to be integers {i,1,5} but Table[10i,{i,1,5}].

  • $\begingroup$ Your own answer of ListPlot[Table[{10i,20i},{i,1,5}]] does not give you what you want? I'm a bit confused about what exactly you want to do. It seems like an easy for us to help if you could perhaps explain it a bit better? $\endgroup$
    – alex
    Commented Mar 26, 2023 at 10:48

1 Answer 1


It is my understanding that your answer should give you a perfectly valid answer. However, let's explore your options, as it is not entirely clear what you want to do:

The Transpose function

The simplest thing I can imagine in terms of what you want to do, is the following:

x = {2, 5, 9, 23, 34}; (* generated either via Table, or just a custom list *)
y = Table[20 i, {i, 5}];
ListPlot[Transpose[{x, y}]]

enter image description here

Dedicated functions

Create a dedicated function that does the trick for you:

fx[x_] := x^2;    (* if you happen to know an analytic expression, do this *)
fy[y_] := 2 y + 1;
ListPlot[Table[{fx[i], fy[i]}, {i, 1, 5}]]

enter image description here

Using DataRange

This is not always the best solution, but it can be very useful if you know that your data are equidistant:

ListPlot[Table[20 i, {i, 5}], DataRange -> {10, 50}]

enter image description here

When you clarify your position I can edit my answer to suit your needs.

Best wishes,



Not the answer you're looking for? Browse other questions tagged or ask your own question.