The speaker begins to tell a story or anecdote about this time when he went to see a really smart astronomer speak.
The word "learn'd" means "smart" or, more accurately, "well-educated." The usual pronunciation of this old-fashioned word would be "learn-ed," with two syllables. It's the kind of word you might hear in a Shakespeare play. But Whitman condenses it down into one syllable: "learn'd."
Whitman uses deliberately folksy speech patterns to poke fun at the astronomer. Just because it's more fun, you should imagine that "learn'd" is spoken in a really thick country accent. It's like saying, "I listened to that there professor fella!"
Astronomy is the study of stars and other heavenly bodies. In the 19th century, scientists didn't yet know about black holes, relativity, and other fun mind-benders. But they did know quite a lot about the solar system, satellite orbits, and even the position of Neptune! (source).
When the proofs, the figures, were ranged in columns before me;
He continues to elaborate on what happened when he heard the astronomer. Right now, it sounds a lot like the astronomer is giving the speaker a private lesson, which is pretty nice of him. We'll see about that one.
The astronomer presents mathematical "proofs," which are demonstrations of the truth of a statement of equation. You might remember having to prove that the three angles of a triangle add up to 180 degrees. The astronomer uses "figures," or numbers, as part of the proofs.
Notice that Whitman never mentions what is being proved. From the poem's perspective, it does not matter.
The figures and proofs are "ranged" (ordered) into columns.
The speaker looks at the astronomer like a really skeptical kid might look at a magician at a party. "He must have it in his left hand now!" Nonetheless, you can tell he seems overwhelmed by all the details.
When I was shown the charts and the diagrams, to add, divide, and measure them;
It still sounds like the speaker is receiving a private lesson in astronomy, and we're still like, "Dude! You should be taking advantage of this."
The astronomer keeps up with his numbers game. He shows visual representations of astronomical phenomena. We assume that "add," "divide," and "measure" are actions performed on numerical qualities ("them"), because you can't really divide a chart or diagram.
By now the speaker seems thoroughly confused. He is reduced to muttering random math phrases. Derivative! Matrices! Quadratic equation! Sorry, we don't know what got into us.
Whitman loves to repeat the same words or phrases at the beginning of successive lines, giving his poetry a chanting quality.
When I, sitting, heard the astronomer, where he lectured with much applause in the lecture-room,
Hey, Walt, when are you going to tell us what happened with the astronomer? Or maybe he just plans to spend the entire poem setting the scene. We're still starting lines with "when." This line zooms out to summarize the atmosphere of the room.
At least our picture of the setting has changed slightly. Suddenly we realize that the speaker is setting in a lecture hall among a crowd of people. The speaker may be confused, but the crowd is loving this astronomer. (We think this is really cool: can you imagine a crowd of average people cheering wildly for an astronomer?)
So, the astronomer is someone very smart who goes around explaining complex scientific ideas to normal people. Kind of like Stephen Hawking, the famous astrophysicist and author of A Brief History of Time.
Public lectures were a popular form of entertainment in the 19th century. Therefore, we don't think that the poem is set in a university or classroom, but rather in one of the many lecture halls that were built in towns and cities around the country.