Dear all,
I am currently trying to create a twoway plot using the European Value Study Time Series.
I have created the following variables for the graph
- abortion_wave: this is a variable that shows the mean abortion atttitudes (1 to 10) per country (24 European countries)
- x_yearEVS: this is a time variable at three time points (1990, 1999 and 2008)
- x_countriesEVS: 24 selected countries.
While the code below works, the graph doesn't look quite as I hoped. I'll attach the graph.
I already tried adjusting the scale via aspectration and ysize and xsize but nothing seems to work. Could you help me?
I'm using Stata 13, if this if of help
I know this is rather basic question but I'm genuinely stuck and neither YouTube nor ChatGTP have helped so far.
Best;
Ruth
This is my code:
local countries 40 56 100 203 208 233 246 250 276 826 348 372 380 428 440 470 528 616 620 642 703 705 724 752
* Define a list of colors
local colors red blue green orange purple brown gray mint pink purple yellow cyan lavender lime magenta olive bluishgray dkorange dkgreen ltblue orange_red dknavy sand
* Initialize an empty list for the plot commands
local plotcmds
* Counter for colors
local color_index 1
* Loop through each country to generate line plot commands
foreach country of local countries {
* Use a color from the predefined list, cycling through colors
local color : word `color_index' of `colors'
* Append each line command to the plot commands list
local plotcmds `plotcmds' (line mean_abortion_wave x_yearEVS if x_countriesEVS == `country', lcolor(`color') lpattern(solid) lwidth(thin))
* Increment the color index, reset if exceeding the number of colors
local color_index = `color_index' + 1
if `color_index' > `:word count `colors'' {
local color_index = 1
}
}
* Generate the overlay plot with all countries
* Generate the overlay plot with all countries
twoway `plotcmds', ///
legend(order(1 "Austria" 2 "Belgium" 3 "Bulgaria" 4 "Czechia" 5 "Denmark" 6 "Estonia" 7 "Finland" 8 "France" 9 "Germany" 10 "Great Britain" ///
11 "Hungary" 12 "Ireland" 13 "Italy" 14 "Latvia" 15 "Lithuania" 16 "Malta" 17 "Netherlands" 18 "Poland" 19 "Portugal" 20 "Romania" ///
21 "Slovakia" 22 "Slovenia" 23 "Spain" 24 "Sweden") size(small) rows(5)) ///
title("Trends of Attitudes towards Abortion Over Time") ///
ytitle("Attitude towards Abortion") ///
xtitle("Year") ///
xlabel(1990 1999 2008, labsize(medium)) ///
ylabel(1 "Never justifiable" 2 3 4 5 6 7 8 9 10 "Always justifiable", angle(0) nogrid) ///
yscale(range(1 10)) ///
aspectratio(2) /// Increase the aspect ratio for a longer y-axis
ysize(20) /// Increase the y-axis length by setting the graph height
xsize(15) /// Optionally, adjust the width to maintain balance
I am currently trying to create a twoway plot using the European Value Study Time Series.
I have created the following variables for the graph
- abortion_wave: this is a variable that shows the mean abortion atttitudes (1 to 10) per country (24 European countries)
- x_yearEVS: this is a time variable at three time points (1990, 1999 and 2008)
- x_countriesEVS: 24 selected countries.
While the code below works, the graph doesn't look quite as I hoped. I'll attach the graph.
I already tried adjusting the scale via aspectration and ysize and xsize but nothing seems to work. Could you help me?
I'm using Stata 13, if this if of help
I know this is rather basic question but I'm genuinely stuck and neither YouTube nor ChatGTP have helped so far.
Best;
Ruth
This is my code:
local countries 40 56 100 203 208 233 246 250 276 826 348 372 380 428 440 470 528 616 620 642 703 705 724 752
* Define a list of colors
local colors red blue green orange purple brown gray mint pink purple yellow cyan lavender lime magenta olive bluishgray dkorange dkgreen ltblue orange_red dknavy sand
* Initialize an empty list for the plot commands
local plotcmds
* Counter for colors
local color_index 1
* Loop through each country to generate line plot commands
foreach country of local countries {
* Use a color from the predefined list, cycling through colors
local color : word `color_index' of `colors'
* Append each line command to the plot commands list
local plotcmds `plotcmds' (line mean_abortion_wave x_yearEVS if x_countriesEVS == `country', lcolor(`color') lpattern(solid) lwidth(thin))
* Increment the color index, reset if exceeding the number of colors
local color_index = `color_index' + 1
if `color_index' > `:word count `colors'' {
local color_index = 1
}
}
* Generate the overlay plot with all countries
* Generate the overlay plot with all countries
twoway `plotcmds', ///
legend(order(1 "Austria" 2 "Belgium" 3 "Bulgaria" 4 "Czechia" 5 "Denmark" 6 "Estonia" 7 "Finland" 8 "France" 9 "Germany" 10 "Great Britain" ///
11 "Hungary" 12 "Ireland" 13 "Italy" 14 "Latvia" 15 "Lithuania" 16 "Malta" 17 "Netherlands" 18 "Poland" 19 "Portugal" 20 "Romania" ///
21 "Slovakia" 22 "Slovenia" 23 "Spain" 24 "Sweden") size(small) rows(5)) ///
title("Trends of Attitudes towards Abortion Over Time") ///
ytitle("Attitude towards Abortion") ///
xtitle("Year") ///
xlabel(1990 1999 2008, labsize(medium)) ///
ylabel(1 "Never justifiable" 2 3 4 5 6 7 8 9 10 "Always justifiable", angle(0) nogrid) ///
yscale(range(1 10)) ///
aspectratio(2) /// Increase the aspect ratio for a longer y-axis
ysize(20) /// Increase the y-axis length by setting the graph height
xsize(15) /// Optionally, adjust the width to maintain balance


Comment