<jupyter_start><jupyter_text><jupyter_code>import matplotlib.pyplot as plt
import numpy as np
plt.plot([2,4,6,8,10])
plt.show()

#plotting with lists
%matplotlib inline
plt.plot([2,5,9,7],[2,1,3,5], color='green', marker='o') #number of x points should be equal to number of y points
plt.xlabel('Bombs')
plt.ylabel('People')
plt.xlim(-5,20)
plt.ylim(0,20)
plt.show()

#plotting with numpy arrays
%matplotlib inline
#arr=np.arange(5,10,0.5)
#plt.plot(arr, arr**2, '1:c', label="y=$x^2$") #using LaTeX for better formatting
#plt.plot(arr, arr, 'or', label="y=x")
#plt.legend()

#plotting on a log scale
plt.loglog(arr, arr, 'or', label="y=x")
plt.loglog(arr, arr**2, '1:c', label="y=$x^2$")
plt.loglog(arr, arr**3, 'b--', label="y=$x^3$")
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.show()

#using only one axis as log scale
t=np.arange(-5,20,0.5)
plt.plot(t, np.exp(t))
plt.yscale('log')
plt.show()

#bar graphs
names=['a','b','c', 'd']
values=np.random.randint(0,25,4)
plt.bar(names,values,color='r')
plt.xlabel("Names")
plt.ylabel("Values")
plt.title("Bar Graph")
plt.show()

#histograms
value=np.random.randn(5000)
plt.hist(value)
plt.show()

#scatterplots
x_values = np.random.randn(1000)
y_values_1 = np.sin(np.pi*x_values) + 0.25*np.random.randn(1000)
y_values_2 = np.cos(np.pi*x_values) + 0.25*np.random.randn(1000)

plt.figure(figsize=(8,6)) 
plt.scatter(x_values,y_values_1,s=10,color='darkorange',label='Sine')
plt.scatter(x_values,y_values_2,s=1,color='indigo',label='Cosine') 
plt.xlabel('x')
plt.ylabel('y')
plt.title('Scatter Plot')
plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2213216957605985, 'fraction_numerical': 0.04551122194513716, 'mean_word_length': 7.065326633165829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '668063', 'license': 'MIT', 'n_tokens_mistral': 783, 'n_tokens_neox': 714, 'n_words': 122, 'path': 'Tutorial 4/Tutorial_4_Plotting.ipynb', 'repo_name': 'drkndl/IITB-Astro-Tutorials', 'size': '1604'}