Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import numpy as np
from matplotlib import pylab as plt
import pandas as pd
import sys
def main():
fname = "result.txt"
outname = "result.png"
df = pd.read_csv(fname, index_col="time (s)")
ax = df.plot(legend=True,
grid=True,
title="Buoyancy simulation",
)
ax.set_xlabel("Time [s]")
ax.set_ylabel("z")
plt.plot()
# plt.show()
plt.savefig(outname, dpi=100)
# fig = plot.get_figure()
# fig.savefig(outname)
if __name__ == "__main__":
main()
time (s), z
0,-80.000000
0,-79.996782
1,-79.990446
2,-79.980992
3,-79.968420
4,-79.952730
5,-79.933922
6,-79.911997
7,-79.886953
8,-79.858791
9,-79.827511
10,-79.793113
11,-79.755597
12,-79.714963
13,-79.671212
14,-79.624342
15,-79.574354
16,-79.521248
17,-79.465024
18,-79.405683
19,-79.343223
20,-79.277645
21,-79.208949
22,-79.137136
23,-79.062204
24,-78.984154
25,-78.903086
26,-78.819000
27,-78.731897
28,-78.641775
29,-78.548635
30,-78.452477
31,-78.353301
32,-78.251107
33,-78.145895
34,-78.037665
35,-77.926416
36,-77.812250
37,-77.695166
38,-77.575163
39,-77.452243
40,-77.326404
41,-77.197647
42,-77.065973
43,-76.931380
44,-76.793969
45,-76.653740
46,-76.510692
47,-76.364827
48,-76.216143
49,-76.064642
50,-75.910322
51,-75.753284
52,-75.593528
53,-75.431053
54,-75.265861
55,-75.097950
56,-74.927321
57,-74.754074
58,-74.578208
59,-74.399725
60,-74.218623
61,-74.034902
62,-73.848564
63,-73.659707
64,-73.468333
65,-73.274439
66,-73.078028
67,-72.879098
68,-72.677750
69,-72.473983
70,-72.267799
71,-72.059196
72,-71.848174
73,-71.634834
74,-71.419176
75,-71.201199
76,-70.980904
77,-70.758391
78,-70.533659
79,-70.306709
80,-70.077540
81,-69.846153
82,-69.612647
83,-69.377023
84,-69.139281
85,-68.899420
86,-68.657540
87,-68.413642
88,-68.167725
89,-67.919790
90,-67.669937
91,-67.418164
92,-67.164473
93,-66.908864
94,-66.651436
95,-66.392189
96,-66.131124
97,-65.868240
98,-65.603637
99,-65.337316
100,-65.069276
101,-64.799517
102,-64.528140
103,-64.255144
104,-63.980529
105,-63.704395
106,-63.426743
107,-63.147572
108,-62.866882
109,-62.584773
110,-62.301246
111,-62.016299
112,-61.729934
113,-61.442250
114,-61.153247
115,-60.862925
116,-60.571385
117,-60.278625
118,-59.984647
119,-59.689549
120,-59.393333
121,-59.095997
122,-58.797543
123,-58.498069
124,-58.197577
125,-57.896065
126,-57.593635
127,-57.290285
128,-56.986017
129,-56.680929
130,-56.375022
131,-56.068296
132,-55.760751
133,-55.452487
134,-55.143503
135,-54.833801
136,-54.523479
137,-54.212538
138,-53.900978
139,-53.588898
140,-53.276299
141,-52.963181
142,-52.649644
143,-52.335687
144,-52.021312
145,-51.706516
146,-51.391402
147,-51.075968
148,-50.760215
149,-50.444242
150,-50.128050
151,-49.811638
152,-49.495107
153,-49.178457
154,-48.861687
155,-48.544898
156,-48.228089
157,-47.911260
158,-47.594512
159,-47.277845
160,-46.961258
161,-46.644851
162,-46.328625
163,-46.012579
164,-45.696714
165,-45.381129
166,-45.065824
167,-44.750800
168,-44.436156
169,-44.121892
170,-43.808008
171,-43.494605
172,-43.181682
173,-42.869239
174,-42.557377
175,-42.246095
176,-41.935392
177,-41.625371
178,-41.316029
179,-41.007367
180,-40.699386
181,-40.392184
182,-40.085763
183,-39.780122
184,-39.475361
185,-39.171480
186,-38.868479
187,-38.566458
188,-38.265417
189,-37.965356
190,-37.666375
191,-37.368474
192,-37.071653
193,-36.775912
194,-36.481351
195,-36.187969
196,-35.895768
197,-35.604846
198,-35.315205
199,-35.026843
200,-34.739761
201,-34.454059
202,-34.169737
203,-33.886794
204,-33.605332
205,-33.325349
206,-33.046845
207,-32.769822
208,-32.494378
209,-32.220514
210,-31.948230
211,-31.677626
212,-31.408701
213,-31.141455
214,-30.875890
215,-30.612104
216,-30.350098
217,-30.089871
218,-29.831424
219,-29.574856
220,-29.320168
221,-29.067360
222,-28.816431
223,-28.567482
224,-28.320512
225,-28.075522
226,-27.832511
227,-27.591580
228,-27.352728
229,-27.115956
230,-26.881263
231,-26.648749
232,-26.418415
233,-26.190261
234,-25.964286
235,-25.740590
236,-25.519174
237,-25.300037
238,-25.083179
239,-24.868601
240,-24.656402
241,-24.446582
242,-24.239142
243,-24.034081
244,-23.831399
245,-23.631197
246,-23.433474
247,-23.238230
248,-23.045466
249,-22.855180
250,-22.667474
251,-22.482348
252,-22.299800
253,-22.119832
254,-21.942443
255,-21.767733
256,-21.595702
257,-21.426351
258,-21.259678
259,-21.095685
260,-20.934371
261,-20.775836
262,-20.620080
263,-20.467104
264,-20.316906
265,-20.169488
266,-20.024849
267,-19.882989
268,-19.744008
269,-19.607906
270,-19.474683
271,-19.344339
272,-19.216875
273,-19.092289
274,-18.970583
275,-18.851855
276,-18.736107
277,-18.623337
278,-18.513547
279,-18.406736
280,-18.302903
281,-18.202050
282,-18.104176
283,-18.009281
284,-17.917365
285,-17.828528
286,-17.742769
287,-17.660090
288,-17.580490
289,-17.503969
290,-17.430527
291,-17.360163
292,-17.292879
293,-17.228674
294,-17.167548
295,-17.109500
296,-17.054532
297,-17.002643
298,-16.953832
299,-16.908201
300,-16.865748
301,-16.826475
302,-16.790380
303,-16.757465
304,-16.727728
305,-16.701170
306,-16.677791
307,-16.657591
308,-16.640570
309,-16.626728
310,-16.616065
311,-16.608581
312,-16.604276
313,-16.603150
314,-16.605202
315,-16.610434
316,-16.618844
317,-16.630434
318,-16.645202
319,-16.663150
320,-16.684276
321,-16.708581
322,-16.736065
323,-16.766728
324,-16.800570
325,-16.837591
326,-16.877791
327,-16.921170
328,-16.967728
329,-17.017465
330,-17.070280
331,-17.126175
332,-17.185149
333,-17.247201
334,-17.312333
335,-17.380544
336,-17.451833
337,-17.526202
338,-17.603649
339,-17.684176
340,-17.767782
341,-17.854466
342,-17.944230
343,-18.037072
344,-18.132894
345,-18.231694
346,-18.333474
347,-18.438233
348,-18.545970
349,-18.656687
350,-18.770383
351,-18.887058
352,-19.006711
353,-19.129244
354,-19.254656
355,-19.382947
356,-19.514118
357,-19.648167
358,-19.785095
359,-19.924902
360,-20.067589
361,-20.213055
362,-20.361299
363,-20.512323
364,-20.666126
365,-20.822708
366,-20.982070
367,-21.144210
368,-21.309030
369,-21.476529
370,-21.646706
371,-21.819564
372,-21.995100
373,-22.173315
374,-22.354110
375,-22.537484
376,-22.723437
377,-22.911970
378,-23.103081
379,-23.296672
380,-23.492743
381,-23.691292
382,-23.892321
383,-24.095829
384,-24.301716
385,-24.509983
386,-24.720629
387,-24.933654
388,-25.149059
389,-25.366743
390,-25.586706
391,-25.808949
392,-26.033471
393,-26.260173
394,-26.489054
395,-26.720115
396,-26.953354
397,-27.188774
398,-27.426273
399,-27.665851
400,-27.907509
401,-28.151246
402,-28.396962
403,-28.644659
404,-28.894334
405,-29.145990
406,-29.399525
407,-29.654939
408,-29.912233
409,-30.171407
410,-30.432360
411,-30.695093
412,-30.959605
413,-31.225897
414,-31.493869
415,-31.763520
416,-32.034851
417,-32.307762
418,-32.582253
419,-32.858323
420,-33.135973
421,-33.415102
422,-33.695712
423,-33.977801
424,-34.261370
425,-34.546319
426,-34.832647
427,-35.120356
428,-35.409344
429,-35.699612
430,-35.991160
431,-36.283988
432,-36.577996
433,-36.873184
434,-37.169551
435,-37.466999
436,-37.765527
437,-38.065134
438,-38.365722
439,-38.667289
440,-38.969837
441,-39.273364
442,-39.577772
443,-39.883059
444,-40.189227
445,-40.496175
446,-40.803903
447,-41.112411
448,-41.421599
449,-41.731468
450,-42.042016
451,-42.353145
452,-42.664854
453,-42.977143
454,-43.290012
455,-43.603362
456,-43.917192
457,-44.231502
458,-44.546192
459,-44.861263
460,-45.176714
461,-45.492445
462,-45.808457
463,-46.124749
464,-46.441221
465,-46.757874
466,-47.074707
467,-47.391621
468,-47.708615
469,-48.025690
470,-48.342745
471,-48.659781
472,-48.976797
473,-49.293793
474,-49.610670
475,-49.927428
476,-50.244066
477,-50.560485
478,-50.876685
479,-51.192665
480,-51.508325
481,-51.823667
482,-52.138688
483,-52.453291
484,-52.767474
485,-53.081238
486,-53.394483
487,-53.707209
488,-54.019415
489,-54.331002
490,-54.641970
491,-54.952318
492,-55.262048
493,-55.571058
494,-55.879349
495,-56.186921
496,-56.493674
497,-56.799608
498,-57.104722
499,-57.408918
500,-57.712194
501,-58.014551
502,-58.315890
503,-58.616209
504,-58.915510
505,-59.213791
506,-59.510953
507,-59.806997
508,-60.101921
509,-60.395627
510,-60.688113
511,-60.979381
512,-61.269430
513,-61.558159
514,-61.845570
515,-62.131663
516,-62.416336
517,-62.699590
518,-62.981426
519,-63.261843
520,-63.540741
521,-63.818120
522,-64.093981
523,-64.368223
524,-64.640846
525,-64.911850
526,-65.181236
527,-65.448903
528,-65.714851
529,-65.979081
530,-66.241592
531,-66.502284
532,-66.761158
533,-67.018213
534,-67.273350
535,-67.526568
536,-67.777867
537,-68.027248
538,-68.274610
539,-68.519954
540,-68.763279
541,-69.004586
542,-69.243774
543,-69.480843
544,-69.715795
545,-69.948627
546,-70.179342
547,-70.407838
548,-70.634115
549,-70.858174
550,-71.080015
551,-71.299537
552,-71.516741
553,-71.731626
554,-71.944193
555,-72.154442
556,-72.362272
557,-72.567684
558,-72.770678
559,-72.971253
560,-73.169410
561,-73.365049
562,-73.558169
563,-73.748771
564,-73.936855
565,-74.122421
566,-74.305368
567,-74.485697
568,-74.663408
569,-74.838501
570,-75.010975
571,-75.180731
572,-75.347769
573,-75.512089
574,-75.673691
575,-75.832574
576,-75.988740
577,-76.142187
578,-76.292816
579,-76.440627
580,-76.585619
581,-76.727794
582,-76.867150
583,-77.003688
584,-77.137309
585,-77.268011
586,-77.395795
587,-77.520661
588,-77.642608
589,-77.761638
590,-77.877750
591,-77.990943
592,-78.101219
593,-78.208476
594,-78.312716
595,-78.413937
596,-78.512140
597,-78.607326
598,-78.699493
599,-78.788642
600,-78.874773
601,-78.957886
602,-79.037981
603,-79.114959
604,-79.188818
605,-79.259559
606,-79.327182
607,-79.391687
608,-79.453074
609,-79.511343
610,-79.566494
611,-79.618528
612,-79.667443
613,-79.713240
614,-79.755919
615,-79.795480
616,-79.831923
617,-79.865249
618,-79.895456
619,-79.922545
620,-79.946516
621,-79.967370
622,-79.985105
623,-79.999722
624,-80.011221
625,-80.019503
626,-80.024566
627,-80.026412
628,-80.025039
629,-80.020449
630,-80.012640
631,-80.001614
632,-79.987370
633,-79.970007
634,-79.949527
635,-79.925929
636,-79.899213
637,-79.869378
638,-79.836426
639,-79.800356
640,-79.761168
641,-79.718862
642,-79.673437
643,-79.624895
644,-79.573235
645,-79.518457
646,-79.460561
647,-79.399547
648,-79.335414
649,-79.268164
650,-79.197796
651,-79.124310
652,-79.047706
653,-78.967984
654,-78.885244
655,-78.799486
656,-78.710709
657,-78.618915
658,-78.524103
659,-78.426273
660,-78.325424
661,-78.221558
662,-78.114673
663,-78.004771
664,-77.891850
665,-77.776012
666,-77.657255
667,-77.535580
668,-77.410987
669,-77.283476
670,-77.153047
671,-77.019700
672,-76.883435
673,-76.744352
674,-76.602450
675,-76.457730
676,-76.310193
677,-76.159837
678,-76.006663
679,-75.850670
680,-75.691960
681,-75.530531
682,-75.366385
683,-75.199520
684,-75.029937
685,-74.857635
686,-74.682716
687,-74.505178
688,-74.325022
689,-74.142248
690,-73.956855
691,-73.768944
692,-73.578515
693,-73.385568
694,-73.190102
695,-72.992118
696,-72.791716
697,-72.588896
698,-72.383657
699,-72.176000
700,-71.965924
701,-71.753530
702,-71.538818
703,-71.321787
704,-71.102438
705,-70.880770
706,-70.656884
707,-70.430780
708,-70.202457
709,-69.971916
710,-69.739256
711,-69.504478
712,-69.267582
713,-69.028567
714,-68.787433
715,-68.544281
716,-68.299110
717,-68.051921
718,-67.802713
719,-67.551587
720,-67.298542
721,-67.043579
722,-66.786697
723,-66.527996
724,-66.267477
725,-66.005139
726,-65.740982
727,-65.475107
728,-65.207513
729,-64.938201
730,-64.667270
731,-64.394720
732,-64.120551
733,-63.844764
734,-63.567457
735,-63.288632
736,-63.008289
737,-62.726426
738,-62.443145
739,-62.158445
740,-61.872326
741,-61.584888
742,-61.296131
743,-61.006056
744,-60.714661
745,-60.422048
746,-60.128216
747,-59.833164
748,-59.536994
749,-59.239705
750,-58.941297
751,-58.641870
752,-58.341424
753,-58.039959
754,-57.737474
755,-57.434071
756,-57.129749
757,-56.824508
758,-56.518447
759,-56.211568
760,-55.903869
761,-55.595451
762,-55.286314
763,-54.976458
764,-54.665982
765,-54.354888
766,-54.043174
767,-53.730841
768,-53.417989
769,-53.104617
770,-52.790726
771,-52.476416
772,-52.161687
773,-51.846538
774,-51.531070
775,-51.215283
776,-50.899176
777,-50.582850
778,-50.266304
779,-49.949539
780,-49.632655
781,-49.315651
782,-48.998528
783,-48.681385
784,-48.364222
785,-48.047040
786,-47.729839
787,-47.412718
788,-47.095678
789,-46.778718
790,-46.461938
791,-46.145339
792,-45.828920
793,-45.512782
794,-45.196923
795,-44.881346
796,-44.566148
797,-44.251331
798,-43.936894
799,-43.622938
800,-43.309461
801,-42.996465
802,-42.684049
803,-42.372214
804,-42.060958
805,-41.750283
806,-41.440288
807,-41.130973
808,-40.822338
809,-40.514483
810,-40.207409
811,-39.901114
812,-39.595700
813,-39.291165
814,-38.987511
815,-38.684837
816,-38.383142
817,-38.082428
818,-37.782694
819,-37.484039
820,-37.186465
821,-36.889971
822,-36.594656
823,-36.300522
824,-36.007567
825,-35.715792
826,-35.425297
827,-35.136082
828,-34.848147
829,-34.561592
830,-34.276416
831,-33.992621
832,-33.710305
833,-33.429469
834,-33.150112
835,-32.872235
836,-32.595939
837,-32.321221
838,-32.048084
839,-31.776526
840,-31.506648
841,-31.238450
842,-30.971931
843,-30.707192
844,-30.444232
845,-30.183052
846,-29.923652
847,-29.666131
848,-29.410490
849,-29.156728
850,-28.904846
851,-28.654944
852,-28.407021
853,-28.161078
854,-27.917114
855,-27.675229
856,-27.435424
857,-27.197699
858,-26.962053
859,-26.728586
860,-26.497299
861,-26.268191
862,-26.041263
863,-25.816514
864,-25.594044
865,-25.373854
866,-25.155943
867,-24.940312
868,-24.727060
869,-24.516187
870,-24.307694
871,-24.101580
872,-23.897845
873,-23.696589
874,-23.497813
875,-23.301516
876,-23.107699
877,-22.916360
878,-22.727601
879,-22.541421
880,-22.357821
881,-22.176799
882,-21.998357
883,-21.822594
884,-21.649510
885,-21.479105
886,-21.311380
887,-21.146333
888,-20.983966
889,-20.824378
890,-20.667569
891,-20.513540
892,-20.362289
893,-20.213818
894,-20.068125
895,-19.925212
896,-19.785178
897,-19.648023
898,-19.513747
899,-19.382350
900,-19.253832
901,-19.128194
902,-19.005434
903,-18.885553
904,-18.768652
905,-18.654729
906,-18.543786
907,-18.435822
908,-18.330836
909,-18.228830
910,-18.129803
911,-18.033754
912,-17.940685
913,-17.850695
914,-17.763784
915,-17.679951
916,-17.599198
917,-17.521524
918,-17.446928
919,-17.375412
920,-17.306975
921,-17.241616
922,-17.179337
923,-17.120137
924,-17.064015
925,-17.010973
926,-16.961009
927,-16.914225
928,-16.870619
929,-16.830193
930,-16.792945
931,-16.758876
932,-16.727986
933,-16.700275
934,-16.675744
935,-16.654391
936,-16.636216
937,-16.621221
938,-16.609405
939,-16.600768
940,-16.595310
941,-16.593030
942,-16.593930
943,-16.598008
944,-16.605266
945,-16.615702
946,-16.629317
947,-16.646112
948,-16.666085
949,-16.689237
950,-16.715568
951,-16.745078
952,-16.777767
953,-16.813635
954,-16.852682
955,-16.894907
956,-16.940312
957,-16.988896
958,-17.040658
959,-17.095500
960,-17.153420
961,-17.214420
962,-17.278498
963,-17.345656
964,-17.415892
965,-17.489208
966,-17.565602
967,-17.645076
968,-17.727628
969,-17.813259
970,-17.901970
971,-17.993759
972,-18.088627
973,-18.186475
974,-18.287301
975,-18.391107
976,-18.497891
977,-18.607655
978,-18.720397
979,-18.836119
980,-18.954820
981,-19.076499
982,-19.201058
983,-19.328496
984,-19.458813
985,-19.592009
986,-19.728084
987,-19.867038
988,-20.008871
989,-20.153484
990,-20.300875
991,-20.451046
992,-20.603996
993,-20.759725
994,-20.918233
995,-21.079520
996,-21.243486
997,-21.410132
998,-21.579456
999,-21.751460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment