Air_density_vs_temperature.svg
Size of this PNG preview of this SVG file:
575 × 431 pixels
.
Other resolutions:
320 × 240 pixels
|
640 × 480 pixels
|
1,024 × 768 pixels
|
1,280 × 959 pixels
|
2,560 × 1,919 pixels
.
Summary
Description Air density vs temperature.svg |
English:
Air density vs. Temperature graph with exponential and 2nd-order polynomial trends. Data from
w:en:Density#Air
|
Date | |
Source | Own work |
Author | T.seppelt |
SVG development
InfoField
|
This plot was created with
Matplotlib
.
|
Source code
InfoField
|
Python codeimport csv, numpy,scipy,scipy.optimize
import matplotlib.pyplot as plt
x = []
y = []
with open("data.csv", "r") as f:
for line in csv.DictReader(f, fieldnames=['x','y'], delimiter=';'):
x.append(int(line['x']))
y.append(float(line['y']))
x = numpy.array(x)
y = numpy.array(y)
intx = numpy.linspace(min(x), max(x), 100)
P1 = numpy.poly1d(numpy.polyfit(x, y, 2))
P2_data = scipy.optimize.curve_fit(lambda t,a,b: a*numpy.exp(b*t), x, y, )[0]
P2 = lambda x : P2_data[0]*numpy.exp(P2_data[1]*x)
plt.scatter(x,y, label="Density of air at 1 atm pressure")
plt.plot(intx, P1(intx), label = "Polynomial Trend\n$x \mapsto 10^{{-5}} x^2 {}x+{}$".format(*numpy.round(P1,4)[1:]))
plt.plot(intx, P2(intx), label = "Exponential Trend\n$x \mapsto \exp({}x) {} $".format(* numpy.round(P2_data,4)))
plt.legend()
plt.xlabel("Temperature [°C]")
plt.ylabel("Density [kg/m³]")
plt.title("Air density vs. temperature")
plt.savefig("output.svg",format="svg",transparent=True)
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the
Creative Commons
Attribution-Share Alike 4.0 International
license.
-
You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
-
Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.