Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scatter plot with bar graph

    Hi,

    I have an issue with plotting a scatter plot combine with bar graph.

    x-axis is exchange rate (usd)
    y-axis is stock market return (mkt)
    bar graph is net supply and net demand

    I would like to plot exchange rate and market return as scatter plot with corresponding net supply and net demand as bar graph only period that net demand or supply not equal to zero but I don't know how to plot this.

    Please refer to the picture below:

    Click image for larger version

Name:	thumbnail_IMG_0396.jpg
Views:	1
Size:	132.8 KB
ID:	1570732


    This is my data

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(monthly usd mkt netsupply netdemand)
    264  -2.0478468  2.6026726 -.36339945  -4.4860897
    265   -3.548061   4.905219 -1.4746455   -6.191761
    266   -2.268332  -.3730015 -1.5177087   -4.958127
    267   2.1891139  -2.417745  1.7183888 -.016695466
    268   -.7965394    2.75148   1.034773    1.235328
    269   -4.806432  -3.081741  -.1064344    .9887276
    270  -.14926174   2.023372  -.9868883   -6.543846
    271  -1.6432375   -8.63042  -.1670051   -2.919932
    272  -1.6013564  -.8948722   .8827286    3.333377
    273   -3.158446  -7.349725  .51623994    .6833113
    274   1.7308536  -2.869434  -.3589642   4.0273294
    275   2.9869945  1.9039277 -1.4439176   -4.123436
    276  -2.0306973   .6909526          0           0
    277   .18168476  2.2888284          0           0
    278   -2.492754   3.283591          0           0
    279  -.02510364  -1.318898          0           0
    280  -1.2056882  3.2190094          0    7.413932
    281  -1.3727076 -.58127767          0           0
    282  -2.2790751   6.712985          0           0
    283  -2.0085866  .28069946          0           0
    284   1.7866004  .14747038          0           0
    285    .2549829  .19207136          0           0
    286  -1.8254682  1.5198965          0           0
    287   -1.056921   3.767254          0           0
    288  -2.1628854   7.489547          0           0
    289    5.019365  1.6776668          0           0
    290    .3332144 -.14918093          0           0
    291   -3.148557  1.3693012          0           0
    292   -.9738461   2.628027          0           0
    293  -2.0366795  -3.996268          0   -3.879605
    294   -3.313439  .28118122          0   -3.170889
    295    .6506623  -4.912808          0   -5.747722
    296  -3.7560015   1.222479          0    8.387284
    297   -.2991006  -.4632317          0           0
    298  -1.3677107  1.4437127          0           0
    299   -1.517194 -1.5099367 -1.3193282           0
    300  -1.2432095 -1.5515237          0           0
    301   -4.976399   .9448336   .7583591           0
    302     6.16092   .8358523          0           0
    303   -.6085969   2.977546          0           0
    304      .33738 -2.0507245          0           0
    305   1.0175719 -1.5831537          0           0
    306    7.399529   1.823915          0           0
    307  -.56519353  3.5563564          0           0
    308    3.045999   5.390651          0           0
    309   1.7724197  .58163613          0           0
    310    2.919131  -2.761727  .57214993           0
    311    .6424765  -2.209427 -1.8585502           0
    312    1.881372   .0390115  -7.228486           0
    313    5.454595 -4.4356527 -11.452032           0
    314   -2.949179   3.479473  -6.914683           0
    315    4.762784   5.959227   5.081755           0
    316    -4.98297 -4.2681546  1.8545836           0
    317    3.490815 -1.7711565 -1.9068682           0
    318    2.231739  4.5845294  -5.160953           0
    319    .6852428  -.6882348   7.192981           0
    320    .8559012    6.62383 -2.0540004    8.609133
    321  -2.0567417  -3.349355          0           0
    322   2.7369986  -.8146685          0           0
    323    1.433118   4.171295   3.849671           0
    324    5.127577   -9.99656          0           0
    325  -.33373895  -1.547396          0           0
    326   2.0369604   .6943071          0           0
    327   1.2747744  3.4344125          0           0
    328   -1.570745  .56554157          0           0
    329   -.5054746 -2.1775107          0           0
    330  -1.1351837  2.2197416          0           0
    331   2.0284727  -2.059003          0           0
    332   -.7645482   3.374284          0    -2.89184
    333    3.448859  2.8669145          0  -2.4535186
    334    5.003475 -1.0862093          0   -13.08276
    335       2.878  -8.394817          0   -6.471038
    336  -4.0246353  -3.604314          0           0
    337  -1.0641106   1.864765          0           0
    338   1.0285614   8.815811          0           0
    339   -.7560795   1.176813          0           0
    340   -2.339489  2.5349166          0           0
    341   -5.294498   2.631751          0           0
    342   -2.862269   3.649575          0           0
    343  -1.2069873   2.827087          0           0
    344  -.12935299  -.8367257          0           0
    345   4.4109654  -.4823661          0           0
    346   2.0764723  1.1829519          0           0
    347  -2.0971348   1.415238          0           0
    348   -3.010541  -3.461796          0           0
    349 -.030732745   5.039765          0           0
    350   -2.588777  4.1222777  4.5398674           0
    351    -7.12883  1.1752771          0           0
    352   -8.811241   3.891067          0           0
    353   -.9347946   9.330248          0           0
    354   -.7597386   -6.05091  -3.531442           0
    355   -3.523827   5.498465          0           0
    356    3.002756   4.945375          0           0
    end
    format %tm monthly





  • #2
    I don't really understand this as in your sketch mkt is on the x axis, not the y axis, and so on but this may get you started.

    Code:
    scatter usd mkt, ms(+) || spike netsupply netdemand mkt
    ​​​​​​​

    Comment

    Working...
    X