<blockquote>
<p>Could you advise on whether Stata is suitable for generating this figure?</p>
</blockquote>
<p>You could definitely generate figure like this in Stata. All the functions you need to plot this exist in Stata. However, Stata is  quite clunky when you want to use other than their default template.</p>
<blockquote>
<p>If not, which software (Stata/R/Python/MATLAB) would you recommend?</p>
</blockquote>
<p>This graph could be created in any of the above mentioned programs and languages.</p>
<p>However, programming languages like R and Python will give you much more control over the aesthetics of the graph. I personally like to create these kind of graphs in R with packages like ggplot2, Python has also good packages.</p>
<p>Hence even though you can use any of them I would personally recommend R or Python. They also both have advantage that they are freeware so you can still work with them  even if your organization does not pay for the expensive license.</p>
<blockquote>
<p>Furthermore, I would appreciate guidance on the appropriate software and commands to achieve this visualization. I have attached an image illustrating the desired figure.</p>
</blockquote>
<p>Without minimal working example it is impossible to give you code that would give you that kind of picture.  At best I can give you packages or functions that perform the calculation.</p>
<p>For example, in Stata you can calculate median of any variable (eg your change in financial constraint), while controlling for some category (in your case those asset terciles) as:</p>
<pre><code>bysort category: egen group_median=median(var)
</code></pre>
<p>To make bar chart like this you will want something like:</p>
<pre><code>webuse turksales, clear
twoway bar var t 
</code></pre>
<p>Of course based on your specific data you might have to do number of other intermediate steps. As mentioned its virtually impossible to just give you code for some arbitrary data.</p>

CC BY-SA 4.0
2024-01-29T16:28:54.063Z
Thank you for your response. I am currently working on Stata, and I will try with R and Python
user282815
CC BY-SA 4.0
2024-01-28T15:53:47.140Z
2024-01-28T15:53:47.140Z
1muflon1
<p>I am looking to create a figure using Stata, specifically a figure depicting the median change in financial constraints over the years, categorized by terciles of total assets and operating cash flow. Additionally, I want to highlight recession periods within the graph.</p>
<p>Could you advise on whether Stata is suitable for generating this figure? If not, which software (Stata/R/Python/MATLAB) would you recommend? Furthermore, I would appreciate guidance on the appropriate software and commands to achieve this visualization. I have attached an image illustrating the desired figure.<a href="https://i.sstatic.net/VwEQ7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/VwEQ7.png" alt="enter image description here" /></a></p>

<stata><r><python><matlab>
Plotting a variable over terciles
user282815
# Plotting a variable over terciles

(Asked by: username_0 on 2024-01-28)

I am looking to create a figure using Stata, specifically a figure depicting the median change in financial constraints over the years, categorized by terciles of total assets and operating cash flow. Additionally, I want to highlight recession periods within the graph.

Could you advise on whether Stata is suitable for generating this figure? If not, which software (Stata/R/Python/MATLAB) would you recommend? Furthermore, I would appreciate guidance on the appropriate software and commands to achieve this visualization. I have attached an image illustrating the desired figure.[![enter image description here](https://i.sstatic.net/VwEQ7.png)](https://i.sstatic.net/VwEQ7.png)

**Tags:** stata, r, python, matlab


---

## 1 answers

### Answer by username_1 on 2024-01-28. Score: 1

Could you advise on whether Stata is suitable for generating this figure?

You could definitely generate figure like this in Stata. All the functions you need to plot this exist in Stata. However, Stata is  quite clunky when you want to use other than their default template.

If not, which software (Stata/R/Python/MATLAB) would you recommend?

This graph could be created in any of the above mentioned programs and languages.
However, programming languages like R and Python will give you much more control over the aesthetics of the graph. I personally like to create these kind of graphs in R with packages like ggplot2, Python has also good packages.
Hence even though you can use any of them I would personally recommend R or Python. They also both have advantage that they are freeware so you can still work with them  even if your organization does not pay for the expensive license.

Furthermore, I would appreciate guidance on the appropriate software and commands to achieve this visualization. I have attached an image illustrating the desired figure.

Without minimal working example it is impossible to give you code that would give you that kind of picture.  At best I can give you packages or functions that perform the calculation.
For example, in Stata you can calculate median of any variable (eg your change in financial constraint), while controlling for some category (in your case those asset terciles) as:
bysort category: egen group_median=median(var)

To make bar chart like this you will want something like:
webuse turksales, clear
twoway bar var t 

Of course based on your specific data you might have to do number of other intermediate steps. As mentioned its virtually impossible to just give you code for some arbitrary data.

> **Comments:**
> **username_0**: Thank you for your response. I am currently working on Stata, and I will try with R and Python  

---

