Reporte Covid19 en México y Michoacán
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.0 KiB

4 years ago
  1. # Preparing data
  2. clear
  3. reset
  4. set datafile separator ","
  5. set datafile missing "NaN"
  6. set bmargin at screen 0.15
  7. set lmargin at screen 0.15
  8. file="../datos/datos-covid-mexico.csv"
  9. set linestyle 1 lc rgb 'black' pt 6 ps 2 # circle
  10. set linestyle 2 lt 0 lw 3.3
  11. FIT_LIMIT = 1e-6
  12. # 1 Expo
  13. set terminal png
  14. set output "1-1.png"
  15. f(x) = a*exp(b*x)
  16. fit f(x) file using 2:3 via a,b
  17. set xlabel 'Días de Contagio' font ',12'
  18. set xtics font ", 11"
  19. show xlabel
  20. set ytics font ", 11"
  21. set ylabel 'Casos Confirmados' font ',14'
  22. set label sprintf("f(x)=%f*e(%f*x)", a, b) at graph 0.01,0.85 font ',12'
  23. set title 'Figura 1: Modelo Exponencial.' font ',16'
  24. show title
  25. set key left top font ',10' box 3
  26. plot [1:][]file using 2:3 title 'Casos' w p ls 1, \
  27. f(x) with lines ls 2 title 'Exponencial'
  28. set output
  29. unset output
  30. unset label
  31. # 2 Polinomico
  32. FIT_LIMIT = 1e-6
  33. f(x) = a*x*x+b*x+c
  34. fit f(x) file using 2:3 via a,b,c
  35. set xtics font ", 13"
  36. show xlabel
  37. set ytics font ", 11"
  38. set ylabel 'Casos confirmados' font ',14'
  39. set label sprintf("f(x)=%f*x^2-%f*x+%f", a, b, c) at graph 0.01,0.85 font ',12'
  40. set title 'Figura 2: Modelo polinomial' font ',16'
  41. show title
  42. set key left top font ',10' box 3
  43. plot file using 2:3 title 'Casos' w p ls 1, \
  44. f(x) with lines ls 2 title 'Polinomial'
  45. set output "1-2.png"
  46. replot
  47. unset output
  48. unset label
  49. # Logaritmico
  50. clear
  51. set datafile separator ","
  52. set datafile missing "NaN"
  53. file="../datos/datos-covid-mexico.csv"
  54. set linestyle 1 lc rgb 'black' pt 6 ps 2 # circle
  55. set linestyle 2 lt 0 lw 3.3
  56. FIT_LIMIT = 1e-6
  57. f(x) = a*x+b
  58. fit f(x) file using 2:9 via a, b
  59. set xlabel 'Días de contagio' font ',14'
  60. set xtics font ", 13"
  61. show xlabel
  62. set ytics font ", 11"
  63. set ylabel 'Casos confirmados' font ',14'
  64. set label sprintf("log(f(x))=%f*x+%f", a, b) at graph 0.01,0.85 font ',12'
  65. set title 'Figura 3: Modelo logarítmico' font ',16'
  66. show title
  67. set key left top font ',10' box 3
  68. plot file using 2:(log($3)) title 'Casos' w p ls 1, \
  69. f(x) with lines ls 2 title 'Log'
  70. set output "1-3.png"
  71. replot
  72. unset output
  73. unset label
  74. # 4 Factor de crecimiento mexico
  75. clear
  76. set linestyle 1 lc rgb 'black' pt 6 ps 2 # circle
  77. set linestyle 2 lt 0 lw 3.3
  78. set xlabel 'Días de contagio' font ',14'
  79. set xtics font ", 13"
  80. show xlabel
  81. set ytics font ", 11"
  82. set ylabel 'Factor de crecimiento' font ',14'
  83. set title 'Figura 4: Factor de crecimeinto díario de COVID19 en México' font ',14'
  84. show title
  85. set key off
  86. plot [1:][] file using 2:4 w lp ls 1
  87. set output "1-4.png"
  88. replot
  89. unset output
  90. unset label
  91. # Incremento diario
  92. clear
  93. reset
  94. FIT_LIMIT = 1e-6
  95. g(x) = c*exp(d*x)
  96. fit g(x) file using 2:6 via c, d
  97. set xlabel 'Días de contagio' font ',14'
  98. set xtics font ", 13"
  99. show xlabel
  100. set ytics font ", 11"
  101. set ylabel 'Incremento de casos diario' font ',14'
  102. set label sprintf("f(x)=%+-f*x%+-f", a, b) at graph 0.01,0.85 font ',12'
  103. set title 'Figura 5: Modelo lineal para incrmento de los casos diarios en México' font ',14'
  104. show title
  105. set key left top font ',10' box 3
  106. plot file using 2:6 title 'Incremento' w lp ls 1, \
  107. g(x) with lines ls 2 title 'Regresor'
  108. set output "1-5.png"
  109. replot
  110. unset output
  111. unset label
  112. # 6 Modelo lineal Michoacan
  113. clear
  114. file2="../datos/datos-covid-michoacan.csv"
  115. f(x) = a*x+b
  116. fit f(x) file2 using 2:3 via a, b
  117. set xlabel 'Días de contagio' font ',14'
  118. set xtics font ", 13"
  119. show xlabel
  120. set ytics font ", 11"
  121. set ylabel 'Casos confirmados' font ',14'
  122. set label sprintf("f(x)=%+-f*x%+-f", a, b) at graph 0.01,0.85 font ',12'
  123. set title 'Figura 6: Modelo lineal para los casos en Michoacán' font ',14'
  124. show title
  125. set key left top font ',10' box 3
  126. plot file2 using 2:3 title 'Casos' w p ls 1, \
  127. f(x) with lines ls 2 title 'Modelo'
  128. set output "1-6.png"
  129. replot
  130. unset output
  131. unset label
  132. # Factor de crecimiento Michoacan
  133. clear
  134. set xlabel 'Días de contagio' font ',14'
  135. set xtics font ", 13"
  136. show xlabel
  137. set ytics font ", 11"
  138. set ylabel 'Factor de crecimiento' font ',14'
  139. set title 'Figura 7: Factor de crecimeinto díario de COVID19 en Michoacán' font ',14'
  140. show title
  141. set key off
  142. plot [1:][] file2 using 2:6 w lp ls 1
  143. set output "1-7.png"
  144. replot
  145. unset output
  146. unset label