# draw points examples
import matplotlib.pyplot as plt

X = [590,540,740,130,810,300,320,230,470,620,770,250]
Y = [32,36,39,52,61,72,77,75,68,57,48,48]

#scatter plot
plt.scatter(X, Y, s=60, c='red', marker='^')

#change axes ranges
plt.xlim(0,1000)
plt.ylim(0,100)

#add title
plt.title('Relationship Between Temperature and Iced Coffee Sales')

#add x and y labels
plt.xlabel('Cups of Iced Coffee Sold')
plt.ylabel('Temperature in Fahrenheit')
#show plot
plt.show()


#Population in European continent EXAMPLE
import plotly.express as px
df = px.data.gapminder().query("year == 2007").query("continent == 'Europe'")

df.loc[ df['pop'] < 2.e6, 'country'] = 'Other countries' # Represent only large countries
fig = px.pie(df, values='pop', names='country', title='Population of European continent')
fig.show()

# draw bars
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.write_html('first_figure.html', auto_open=True)


# Plot function - new example
import matplotlib.pyplot as plt
import numpy as np

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()

fig.savefig("ch7_sin_funct_test.png")
plt.show() 



"""works on IDLE -– post at the file root """
import plotly.graph_objects as go
import plotly.io as pio

fig = go.Figure(go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1]))
fig.update_layout(title_text='hello world')
pio.show(fig)

"""works on IDLE - copy result into a file 'hello_world.html and open it up """
import plotly.graph_objects as go
import plotly.io as pio
fig = go.Figure(go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1]))
fig.update_layout(title_text='hello world')
pio.write_html(fig, file='hello_world.html', auto_open=True)



"""import plotly.plotly as py
import plotly.graph_objs as go
import chart_studio.plotly as py
import plotly.graph_objects as go'"""
"""
labels = ['Data Mining','Machine Learning','Statistics','Programming']
values = [150000,145000,135000,125000]

chart1 = go.Pie(labels=labels, values=values)

py.plot([chart1])

"""

"""
import chart_studio.plotly as py
import plotly.graph_objects as go


trace0 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)
trace1 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)
data = [trace0, trace1]

py.plot(data, filename = 'basic-line')
"""
