# Mathematica- filling to y-axis

• Mathematica
• cryptist
In summary, to plot on the y-axis in Mathematica, you use the following command: /. List[x_, y_] -> List[y, x]

#### cryptist

Filling->Axis command makes vertical lines to the x-axis. How can I make same thing for the y-axis? (Horizontal lines to the y-axis)

Study all the responses here and see if you can adapt it to what you need

http://stackoverflow.com/questions/6204898/plotting-on-the-y-axis-in-mathematica

This might not be an understandable or easy or dependable thing to do.

Start by trying to reproduce exactly the examples that they show. Then make very small changes and see if it continues to work. Try to figure out what went wrong and how to possibly correct it if it fails. Gradually work up to the actual problem you have.

Last edited:
I used this command: /. List[x_, y_] -> List[y, x]
But I guess it does not work for ListPlot. Mathematica didn't draw anything when I use that command. My data contains points generated by ListPlot and I want to draw horizontal filling lines from points to the y-axis.

Post the smallest simplest example dataset you can construct along with a simple clear explanation of what you want the result to look like and perhaps someone can see a way to accomplish what you are looking for.

Here is an example:

ListPlot[Table[{x, x*x}, {x, 1, 5, 1}], Filling -> Bottom,
PlotStyle -> {Black, PointSize[0.015]}]

When you plot the code above, there will be a filling from points to x-axis. I want also a filling from points to y-axis.

How can I do that?

Thank you. A good simple clear concrete example makes it much more likely to give you an answer like you are looking for.

In[1]:= Show[{
ListPlot[Table[{x, x*x}, {x, 1, 5, 1}], Filling -> Bottom, PlotStyle -> {Black, PointSize[0.015]}],
Graphics[Table[Line[{{1, x^2}, {x, x^2}}], {x, 1, 5, 1}]]
}]

Out[1]= ...PlotSnipped...

Then, only if you really need to, you spend minutes or hours or days fiddling with the hundreds of options and directives to adjust the style to try to get close to exactly what you want.

Last edited:
1 person

## 1. What is the purpose of "Mathematica- filling to y-axis"?

The "Mathematica- filling to y-axis" function is used to fill the area under a curve or between two curves up to the y-axis. This can be helpful in visualizing data or highlighting specific regions of a graph.

## 2. How do I use the "Mathematica- filling to y-axis" function?

To use this function, you need to have a plot or list of data points. Then, you can specify the filling option as "Axis" in the plot or ListPlot command. This will fill the area under the curve(s) up to the y-axis.

## 3. Can I fill to a specific y-value instead of the y-axis?

Yes, you can specify a specific y-value for filling by using the "Filling -> {y-value}" option in the plot or ListPlot command. This will fill the area under the curve(s) up to the specified y-value.

## 4. Can I use different colors for the filling in "Mathematica- filling to y-axis"?

Yes, you can use the "FillingStyle" option to specify different colors for the filling. This allows you to highlight different regions of the graph with different colors.

## 5. Is "Mathematica- filling to y-axis" only for 2D plots?

No, this function can also be used for 3D plots. In this case, the filling will extend from the surface of the plot down to the specified y-value or y-axis.