The airticle shows how to display list in python and mathematica with a few examples.
The examples come from An Elementary Introduction To The Wolfram Language
Make a bar chart of { 1, 1, 2, 3, 5 }
Python:
import matplotlib.pyplot as plt y = (1,1,2,3,5) x = range( len(y)+1 ) x = x[1:] #slice to store [1,2,3,4,5] plt.bar( x, y, align='center' ) plt.xticks( x ) plt.show()
![](https://www.weiy.city/wp-content/uploads/2019/04/c8aa69f7-d8fa-4d32-95c2-ff415f6867b2.png)
Wolfram:
BarChart[{1,1,2,3,5}]
![](https://www.weiy.city/wp-content/uploads/2019/04/95c4887c-db03-4f10-b4a9-03dc3e0972e2.png)
Make a pie chart of numbers from 1 to 10
Python:
import matplotlib.pyplot as plt values = range(1,11) labels = ['1','2','3','4','5','6','7','8','9','10'] # colors refrence link: https://en.wikipedia.org/wiki/Web_colors colors = ["DarkOliveGreen", "Olive", "OliveDrab", "YellowGreen", "LimeGreen", "Lime", "LawnGreen", "Chartreuse", "GreenYellow", "SpringGreen", "MediumSpringGreen", "LightGreen", "PaleGreen", "DarkSeaGreen", "MediumAquamarine", "MediumSeaGreen"] plt.pie( values, labels=labels, autopct='%1.1f%%', colors = colors ) plt.axis( 'equal' ) plt.show()
![](https://www.weiy.city/wp-content/uploads/2019/04/10ba9f9d-6b3c-4115-9dfc-c3b57819b8be.png)
Wolfram:
Values=Range[10] Labels={"1","2","3","4","5","6","7","8","9","10"} PieChart[Values, ChartLabels→ Labels]
![](https://www.weiy.city/wp-content/uploads/2019/04/44228425-22aa-4f34-a5a7-57efaf583549.png)
Display numbers from 5 to 1 in a line
Python:
import matplotlib.pyplot as plt data1 = list( range( 1, 6 ) ) x = data1 data1.reverse() plt.grid( True ) plt.plot( x, data1 ) #plt.xticks( x ) # adjust unit length of X axis plt.show()
![](https://www.weiy.city/wp-content/uploads/2019/04/ec7f245c-8f30-4bef-b61e-a857dcb48642.png)
Wolfram:
ListLinePlot[{5,4,3,2,1}]
![](https://www.weiy.city/wp-content/uploads/2019/04/6918273c-e692-4c34-b02e-a67af874221d.png)
Display numbers from 1 to 5 in a column
Python:
import numpy as np print( np.array(range(1,6)).reshape(5,1) )
output:
[[1] [2] [3] [4] [5]]
Wolfram:
Column[{1,2,3,4,5}]
![](https://www.weiy.city/wp-content/uploads/2019/04/a9c54c6b-84d0-4cd5-b95d-f4c48da0dac1.png)
Make a number line plot of the squares {1, 4, 9, 16, 25}
Python:
import matplotlib.pyplot as plt x = [1] for it in range( 2, 6 ): x.append( it*it ) y = [1,1,1,1,1] print( x ) plt.xticks( range(1,26) ) plt.grid( True ) plt.plot( x, y, "ro" ) plt.show()
![](https://www.weiy.city/wp-content/uploads/2019/04/64e372f3-c0ea-4eed-a8ab-6aceb981e7cb.png)
Wolfram:
![](https://www.weiy.city/wp-content/uploads/2019/04/463625e6-7030-45ab-b4c3-e21b06517ffa.png)
Make a column pf pie chart with 1, 2 and 3 identical segments
Wolfram:
Column[{PieChart[{1}],PieChart[{1,1}],PieChart[{1,1,1}]}]
![](https://www.weiy.city/wp-content/uploads/2019/04/14ea830b-279b-49dc-bf2a-ad129127be24.png)