palette = [("A","green"),("B","blue"),("C","red")] labels = { "A": "The A Party", "B":"The B Party", "C":"C Party" } seats = { "A": 25, "B": 21, "C": 8 } votes = { "A": 2012311, "B": 1900000, "C": 1500000 } p = Diagram() n = p.addNarrative() n.addText("Hemicycle Example",font_size=50,font_style={"stroke":"purple"}) n.addText("Election Results",font_size=28,font_style={"font-weight":"bold"}) n.addSpace(20,20) h = HemiCycle(palette,labels) h.addContinuousPlot("Election Votes", 200, 300, votes) h.addDiscretePlot("Parliamentary Seats", 50, 150, seats) n.add(h) n.addSpace(20,20) n.addLegend(palette,labels,700,legend_columns=3) svg = p.draw() folder = os.path.split(sys.argv[0])[0] outputpath = os.path.join(folder,"example.svg")
palette = [("A", "green"), ("B", "blue"), ("C", "red")] labels = {"A": "The A Party", "B": "The B Party", "C": "C Party"} seat_changes = { "AnyTown": ("A", "B"), "SmallTown": ("A", "B"), "BigTown": ("B", "C"), "SeaTown": ("B", "A"), "HillTown": ("A", "C"), "StrangeTown": ("A", "B"), "NowhereTown": ("B", "C"), "FunnyTown": ("A", "B") } d = Diagram() p = d.addNarrative() p.addText("Election Results", font_size=32, font_style={"stroke": "purple"}) p.addText("Seats changing party, %s election - %s election" % ("2009", "2011"), font_size=28, font_style={"font-weight": "bold"}) p.add( Transition(1024, 512, seat_changes, palette, labels, axis_labels=["2009", "2011"]))
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from pyinfog.diagram import Diagram import os import sys if __name__ == "__main__": folder = os.path.split(sys.argv[0])[0] d = Diagram() n0 = d.addNarrative() n0.addImage( "image/jpeg", open(os.path.join(folder, "..", "..", "..", "pyinfog.jpg"), "rb").read(), 290, 82, "python logo") n0.addText("Infographic Gallery", font_size=48) n1 = n0.addNarrative() infogs_folder = os.path.join(folder, "..", "..", "infogs") row = 0 for infog_folder in os.listdir(infogs_folder): if os.path.exists( os.path.join(infogs_folder, infog_folder, "example.svg")):