Drawing a simple line graph in Java

Problems with your code and suggestions: Again you need to change the preferredSize of the component (here the Graph JPanel), not the size Don’t set the JFrame’s bounds. Call pack() on your JFrame after adding components to it and before calling setVisible(true) Your foreach loop won’t work since the size of your ArrayList is 0 … Read more

Plot multiple lines in one graph [duplicate]

You should bring your data into long (i.e. molten) format to use it with ggplot2: library(“reshape2″) mdf <- melt(mdf, id.vars=”Company”, value.name=”value”, variable.name=”Year”) And then you have to use aes( … , group = Company ) to group them: ggplot(data=mdf, aes(x=Year, y=value, group = Company, colour = Company)) + geom_line() + geom_point( size=4, shape=21, fill=”white”)