![]() ![]() Now obviously, the longer the number of entries are, the busier and the more cluttered the graphs become and it starts looking a bit ugly, but it is still legible. ![]() This resulted in the following graphs for the Xia dynasty:Īnd using a bigger subset, I could generate this other graph too: plt.vlines(begin+length/2, 0, levels, color="tab:red") I played around a bit with vertical lines for labels and the labels were associated with the levels to create the plot. ![]() plt.barh(0, (end-begin), color=data_set_xia.loc, height =0.3 ,left=begin, edgecolor = "black") Here I basically add all of the dynasties on the same y scalar (listed as 0), the rest of the line has been modified to correspond to the color of the bars and give an edgecolour. Here I added a level for naming with a vertical line (you can lengthen or shorten the array to get different levels of labelling): levels = np.tile(, Then for the purpose of replicating your Xia Dynasty representation, I just created a subset:įollowing that I kept mostly to what your/Evgeny's code already shows with a few minor changes: event = data_set_xia I created a dataframe from the google dataset and assigned each of the Dynasty (Dynasty_col column) and Age (Age_col column) with a matplotlib CSS color (this is not necessary, but, I find this easier to manage for visualisation): So, I took the liberty of downloading your dataset and playing around with the code a little bit. So, each successive stacked bar is being listed on a separate level. I don't know whether you already resolved this problem or not, but, from what I have seen so far from your code and (also borrowing from Evgeny's code) your requirements, the only reason you have the different levels of horizontal bars because you have defined the scalar y of the barh of matplotlib ( (y, width, height=0.8, left=None, *, align='center', **kwargs) as a range. I've been trying to figure this out for about two weeks now and am hitting a brick wall. This code semi-works, but I'd prefer if the bars were either closer together or differently colored and all on the same y-value. Plt.text(begin.iloc + length.iloc/2, i+.25, event.iloc, ha='center', fontsize = '12') Plt.title('Xia Dynasty', fontsize = '25') Plt.tick_params(axis='both', which='minor', labelsize=20) Plt.tick_params(axis='both', which='major', labelsize=15) Here's the code I used to produce both of these (I just modified the included code in order to change which section of the overall dataset was used). The issue becomes more apparent when I try and work with larger segments, such as this one, which is basically unreadable: ![]() I don't know how to flatten it out so that it looks like a traditional timeline. I've included a picture of one attempted solution, which was found at this link: To give a sense of what I'm working with, here's a link to the full dataset. So I've seen a few answers on here that helped a bit, but my dataset is larger than the ones that have been answered previously. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |