# How can I draw 2 series in the same chart

I was able to plt the first series as:

``````using Gadfly

history = [30,21,29,31,40,48,53,47,37,39,31,29,17,9,20,24,27,35,41,38,
27,31,27,26,21,13,21,18,33,35,40,36,22,24,21,20,17,14,17,19,
26,29,40,31,20,24,18,26,17,9,17,21,28,32,46,33,23,28,22,27,
18,8,17,21,31,34,44,38,31,30,26,32];

plot(y=history, Geom.line)
``````

Now I’ve another series as:

``````forecast = [28, 30, 19, 45]
``````

In the same chart I want to draw the second series as a continuity of the first series, but with different line colors, something like:

A basic example:

``````labels = vcat(fill.(["series","forecast"], [90,10])...)
df = DataFrame(time=1:100, y=cumsum(randn(100)), id=labels)
p = plot(df, x=:time, y=:y, Geom.line, color=:id)
``````

Did not get where and how shall I use my series actual data or actual names?

``````labels = vcat(fill.(["history", "forecast"], [72, 4])...)
df = DataFrame(time=1:76, y=vcat(history, forecast), id=labels)

``````
1 Like

Thanks,

But what if the first point of the second series is the last point of the first series, how can I connect them together, in the example beow, I need both lines to be connected to point number 5, and both lines connected together at this point, as you see below there is a gap, how can I get rid of this gap and connect the lines together at point 5

``````using Gadfly, DataFrames
history=[1,2,3,4,5]
forecast=[5,6,7,8,9]
labels = vcat(fill.(["history", "forecast"], [5, 5])...)
df = DataFrame(time=1:10, y=vcat(history, forecast), id=labels)
p = plot(df, x=:time, y=:y, Geom.line, color=:id)
``````

You didn’t heart my converted rust code:

was giving priority for the plotting

In the above example plot, you need to start the gold line at time=5.0. Currently in the dataframe, the gold line starts at point time=6.0. i.e. both the history and forecast need a point at time=5.0

It starts at point 6 in the plot, but in the array itself it starts at point 5 `forecast=[5,6,7,8,9]`

so in the DataFrame, `time=vcat(1:5,5:9)`

1 Like

Thanks, mm, hope this to be the last for this point, how can I select the line color my self for each series, instead of `color=:id`