![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195790/image.png)
How do I create multiple parallel lines
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Cliff Karlsson
am 15 Sep. 2018
Kommentiert: jonas
am 16 Sep. 2018
How do I create parallel lines in a certain interval like in the picture? I am pretty sure I can use line() but I have not managed to understand how.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195914/image.png)
0 Kommentare
Akzeptierte Antwort
Stephen23
am 16 Sep. 2018
Bearbeitet: Stephen23
am 16 Sep. 2018
Plotting lots of lines is not the correct solution, you should use the grid command, or set the axes grid properties (e.g. adjust tick-mark positions, grid linestyle, grid color, grid transparency, etc.). The MATLAB documentation gives examples of how to adjust the grid lines:
This should get you started:
>> x = -10:0.1:10;
>> y = 100*sin(x);
>> plot(x,y,'-.')
>> ylim([-150,150])
>> set(gca,'YGrid','on') % Turn on the Y-grid. Also: color, linestyle, etc.
Produces this plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195790/image.png)
1 Kommentar
jonas
am 16 Sep. 2018
Cant believe I never realized you could customize the grid properties. The doc is pretty useful sometimes. +1
Weitere Antworten (1)
Image Analyst
am 15 Sep. 2018
If you're not fussy about the way the lines look, you can simply call
grid on;
Also, if you want the x and y axis in there at the right place, instead of outside the plotting box, you can do
ax = gca
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
0 Kommentare
Siehe auch
Kategorien
Mehr zu Formatting and Annotation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!